dhcp: check array bounds before accessing it (bug #36170)

This commit is contained in:
goldsimon 2012-05-03 20:21:50 +02:00
parent d690775ca1
commit 1704d21356

View File

@ -567,12 +567,10 @@ dhcp_handle_ack(struct netif *netif)
#if LWIP_DNS
/* DNS servers */
n = 0;
while(dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n) && (n < DNS_MAX_SERVERS)) {
for(n = 0; (n < DNS_MAX_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n); n++) {
ip_addr_t dns_addr;
ip4_addr_set_u32(&dns_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n)));
dns_setserver(n, &dns_addr);
n++;
}
#endif /* LWIP_DNS */
}