dhcp: 2 small code improvements

See bugs #54226 and #54228
This commit is contained in:
Simon Goldschmidt 2018-07-02 20:27:12 +02:00
parent 19a929f5fb
commit 1e24f9c9cd

View File

@ -1685,7 +1685,7 @@ decode_next:
if (offset >= q->len) { if (offset >= q->len) {
offset = (u16_t)(offset - q->len); offset = (u16_t)(offset - q->len);
offset_max = (u16_t)(offset_max - q->len); offset_max = (u16_t)(offset_max - q->len);
if ((offset < offset_max) && offset_max) { if (offset < offset_max) {
q = q->next; q = q->next;
LWIP_ERROR("next pbuf was null", q != NULL, return ERR_VAL;); LWIP_ERROR("next pbuf was null", q != NULL, return ERR_VAL;);
options = (u8_t *)q->payload; options = (u8_t *)q->payload;
@ -1785,7 +1785,7 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
goto free_pbuf_and_return; goto free_pbuf_and_return;
} }
/* iterate through hardware address and match against DHCP message */ /* iterate through hardware address and match against DHCP message */
for (i = 0; i < netif->hwaddr_len && i < NETIF_MAX_HWADDR_LEN && i < DHCP_CHADDR_LEN; i++) { for (i = 0; i < netif->hwaddr_len && i < LWIP_MIN(DHCP_CHADDR_LEN, NETIF_MAX_HWADDR_LEN); i++) {
if (netif->hwaddr[i] != reply_msg->chaddr[i]) { if (netif->hwaddr[i] != reply_msg->chaddr[i]) {
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n", ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n",