Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d60dc7ef authored by tintin's avatar tintin Committed by android-build-merger
Browse files

libnetutil: Check dhcp respose packet length am: 61f25d4a am: cee6d38c am:...

libnetutil: Check dhcp respose packet length am: 61f25d4a am: cee6d38c am: 29d05404 am: c29049f4 am: 3de04e98 am: 19702dc4 am: 8191e9ba am: 804323c1 am: 4f5f00d8 am: 3a1ff1ad am: bab7b1ec am: cdf0fc60
am: 9f1398c6

Change-Id: I4c46a36846dd8f6588f29bc84de9bc3f1d7c088a
parents fdd67a54 9f1398c6
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -218,6 +218,20 @@ int receive_packet(int s, struct dhcp_msg *msg)
     * to construct the pseudo header used in the checksum calculation.
     */
    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;
    daddr = packet.ip.daddr;
    nread = ntohs(packet.ip.tot_len);