Skip to content
Snippets Groups Projects
Commit d4e14aba authored by android-build-prod (mdb)'s avatar android-build-prod (mdb) Committed by Gerrit Code Review
Browse files

Merge "Snap for 4526935 from d60dc7ef to...

Merge "Snap for 4526935 from d60dc7ef to oreo-mr1-cts-release" into oreo-mr1-cts-release
parents f469ebae 31777310
No related branches found
No related tags found
No related merge requests found
...@@ -218,6 +218,20 @@ int receive_packet(int s, struct dhcp_msg *msg) ...@@ -218,6 +218,20 @@ int receive_packet(int s, struct dhcp_msg *msg)
* to construct the pseudo header used in the checksum calculation. * to construct the pseudo header used in the checksum calculation.
*/ */
dhcp_size = ntohs(packet.udp.len) - sizeof(packet.udp); dhcp_size = ntohs(packet.udp.len) - sizeof(packet.udp);
/*
* check validity of dhcp_size.
* 1) cannot be negative or zero.
* 2) src buffer contains enough bytes to copy
* 3) cannot exceed destination buffer
*/
if ((dhcp_size <= 0) ||
((int)(nread - sizeof(struct iphdr) - sizeof(struct udphdr)) < dhcp_size) ||
((int)sizeof(struct dhcp_msg) < dhcp_size)) {
#if VERBOSE
ALOGD("Malformed Packet");
#endif
return -1;
}
saddr = packet.ip.saddr; saddr = packet.ip.saddr;
daddr = packet.ip.daddr; daddr = packet.ip.daddr;
nread = ntohs(packet.ip.tot_len); nread = ntohs(packet.ip.tot_len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment