Commit 2feac3ed authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Allocate neighbour later.

Only allocate the neighbour after all the basic sanity checks have been
performed.  This is important in the HMAC branch.
parent f53f4863
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment