From 1e24f9c9cd81f516c60366b49b7fc18c51156f3c Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Mon, 2 Jul 2018 20:27:12 +0200 Subject: [PATCH] dhcp: 2 small code improvements See bugs #54226 and #54228 --- src/core/ipv4/dhcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index adfc5fa8..3946b63b 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -1685,7 +1685,7 @@ decode_next: if (offset >= q->len) { offset = (u16_t)(offset - q->len); offset_max = (u16_t)(offset_max - q->len); - if ((offset < offset_max) && offset_max) { + if (offset < offset_max) { q = q->next; LWIP_ERROR("next pbuf was null", q != NULL, return ERR_VAL;); 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; } /* 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]) { 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",