Add 2 more length/bounds checks with thanks to
Guido Vranken <guido@guidovranken.com>
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
break;
opt = (void *) &opt->data[opt->len];
+ if ((uint8_t *) opt + sizeof(*opt) > end )
+ break;
switch(opt->code) {
case DHCP_OPTION_ROUTER:
DPRINTF(2, "Found a DHCP router option, len=%d\n", opt->len);
udp = (void *) ((char *) &pkt->iph + (pkt->iph.ihl << 2));
dhcp = (void *) (udp + 1);
- if ((uint8_t *)udp + sizeof(*udp) > (uint8_t *)data + len )
+ if ((uint8_t *)udp + sizeof(*udp) > (uint8_t *)data + len ||
+ (uint8_t *)dhcp + sizeof(*dhcp) > (uint8_t *)data + len)
return false;
udplen = ntohs(udp->len);