check payload length validity
make sure the payload does not exceed the amount of data received
This commit is contained in:
parent
ac0ec1f6b3
commit
76b017aefd
@ -87,8 +87,13 @@ void _native_handle_tap_input(void)
|
|||||||
/* XXX: check overflow */
|
/* XXX: check overflow */
|
||||||
p.length = ntohs(frame.field.payload.nn_header.length);
|
p.length = ntohs(frame.field.payload.nn_header.length);
|
||||||
p.data = frame.field.payload.data;
|
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);
|
if (p.length > (nread - sizeof(struct nativenet_header))) {
|
||||||
_nativenet_handle_packet(&p);
|
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 {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user