Skip to content

Commit c34b997

Browse files
committed
Merge tag 'android-8.1.0_r4' into lineage-15.1
Android 8.1.0 Release 4 (OPM1.171019.013) # gpg: Signature made Tue Jan 2 18:42:55 2018 CST # gpg: using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78 # gpg: Good signature from "The Android Open Source Project <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 4340 D135 70EF 945E 8381 0964 E8AD 3F81 9AB1 0E78
2 parents eb4c2ca + 9f30f3b commit c34b997

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libnetutils/packet.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,20 @@ int receive_packet(int s, struct dhcp_msg *msg)
218218
* to construct the pseudo header used in the checksum calculation.
219219
*/
220220
dhcp_size = ntohs(packet.udp.len) - sizeof(packet.udp);
221+
/*
222+
* check validity of dhcp_size.
223+
* 1) cannot be negative or zero.
224+
* 2) src buffer contains enough bytes to copy
225+
* 3) cannot exceed destination buffer
226+
*/
227+
if ((dhcp_size <= 0) ||
228+
((int)(nread - sizeof(struct iphdr) - sizeof(struct udphdr)) < dhcp_size) ||
229+
((int)sizeof(struct dhcp_msg) < dhcp_size)) {
230+
#if VERBOSE
231+
ALOGD("Malformed Packet");
232+
#endif
233+
return -1;
234+
}
221235
saddr = packet.ip.saddr;
222236
daddr = packet.ip.daddr;
223237
nread = ntohs(packet.ip.tot_len);

0 commit comments

Comments
 (0)