Allocate neighbour later.
Only allocate the neighbour after all the basic sanity checks have been
performed.  This is important in the HMAC branch.
@@ -480,12 +480,6 @@ parse_packet(const unsigned char *from, struct interface *ifp,
return;
}
- neigh = find_neighbour(from, ifp);
- if(neigh == NULL) {
- fprintf(stderr, "Couldn't allocate neighbour.\n");
- return;
- }
-
DO_NTOHS(bodylen, packet + 2);
if(bodylen + 4 > packetlen) {
@@ -494,6 +488,12 @@ parse_packet(const unsigned char *from, struct interface *ifp,
bodylen = packetlen - 4;
}
+ neigh = find_neighbour(from, ifp);
+ if(neigh == NULL) {
+ fprintf(stderr, "Couldn't allocate neighbour.\n");
+ return;
+ }
+
i = 0;
while(i < bodylen) {
message = packet + 4 + i;
