]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
dhcp: check array bounds before accessing it (bug #36170)
authorgoldsimon <goldsimon@gmx.de>
Thu, 3 May 2012 18:21:50 +0000 (20:21 +0200)
committergoldsimon <goldsimon@gmx.de>
Thu, 3 May 2012 18:21:50 +0000 (20:21 +0200)
src/core/dhcp.c

index 701210392af95079cf98f93f7c0fb749ffd1559f..614fa324541f1b9d37c68c097f311c41a0ebd648 100644 (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 */
 }