Skip to content

Commit

Permalink
check payload length validity
Browse files Browse the repository at this point in the history
make sure the payload does not exceed the amount of data received
  • Loading branch information
LudwigKnuepfer committed Jan 8, 2014
1 parent ac0ec1f commit 76b017a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cpu/native/net/tap.c
Expand Up @@ -87,8 +87,13 @@ void _native_handle_tap_input(void)
/* XXX: check overflow */
p.length = ntohs(frame.field.payload.nn_header.length);
p.data = frame.field.payload.data;
DEBUG("_native_handle_tap_input: received packet of length %"PRIu16" for %"PRIu16" from %"PRIu16"\n", p.length, p.dst, p.src);
_nativenet_handle_packet(&p);
if (p.length > (nread - sizeof(struct nativenet_header))) {
warnx("_native_handle_tap_input: packet with malicious length field received, discarding");
}
else {
DEBUG("_native_handle_tap_input: received packet of length %"PRIu16" for %"PRIu16" from %"PRIu16"\n", p.length, p.dst, p.src);
_nativenet_handle_packet(&p);
}
}
}
else {
Expand Down

0 comments on commit 76b017a

Please sign in to comment.