mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-23 14:46:01 +00:00
dhcp: don't use LWIP_ERROR in dhcp_parse_reply()
See bug #56643 Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
parent
6b3ed88d9c
commit
c53a8444e8
|
@ -128,6 +128,11 @@
|
||||||
#define LWIP_DHCP_PROVIDE_DNS_SERVERS 0
|
#define LWIP_DHCP_PROVIDE_DNS_SERVERS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LWIP_DHCP_INPUT_ERROR
|
||||||
|
#define LWIP_DHCP_INPUT_ERROR(message, expression, handler) do { if (!(expression)) { \
|
||||||
|
handler;} } while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Option handling: options are parsed in dhcp_parse_reply
|
/** Option handling: options are parsed in dhcp_parse_reply
|
||||||
* and saved in an array where other functions can load them from.
|
* and saved in an array where other functions can load them from.
|
||||||
* This might be moved into the struct dhcp (not necessarily since
|
* This might be moved into the struct dhcp (not necessarily since
|
||||||
|
@ -1551,58 +1556,58 @@ again:
|
||||||
/* will be increased below */
|
/* will be increased below */
|
||||||
break;
|
break;
|
||||||
case (DHCP_OPTION_SUBNET_MASK):
|
case (DHCP_OPTION_SUBNET_MASK):
|
||||||
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 4", len == 4, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_SUBNET_MASK;
|
decode_idx = DHCP_OPTION_IDX_SUBNET_MASK;
|
||||||
break;
|
break;
|
||||||
case (DHCP_OPTION_ROUTER):
|
case (DHCP_OPTION_ROUTER):
|
||||||
decode_len = 4; /* only copy the first given router */
|
decode_len = 4; /* only copy the first given router */
|
||||||
LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_ROUTER;
|
decode_idx = DHCP_OPTION_IDX_ROUTER;
|
||||||
break;
|
break;
|
||||||
#if LWIP_DHCP_PROVIDE_DNS_SERVERS
|
#if LWIP_DHCP_PROVIDE_DNS_SERVERS
|
||||||
case (DHCP_OPTION_DNS_SERVER):
|
case (DHCP_OPTION_DNS_SERVER):
|
||||||
/* special case: there might be more than one server */
|
/* special case: there might be more than one server */
|
||||||
LWIP_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;);
|
||||||
/* limit number of DNS servers */
|
/* limit number of DNS servers */
|
||||||
decode_len = LWIP_MIN(len, 4 * DNS_MAX_SERVERS);
|
decode_len = LWIP_MIN(len, 4 * DNS_MAX_SERVERS);
|
||||||
LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_DNS_SERVER;
|
decode_idx = DHCP_OPTION_IDX_DNS_SERVER;
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */
|
#endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */
|
||||||
case (DHCP_OPTION_LEASE_TIME):
|
case (DHCP_OPTION_LEASE_TIME):
|
||||||
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 4", len == 4, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_LEASE_TIME;
|
decode_idx = DHCP_OPTION_IDX_LEASE_TIME;
|
||||||
break;
|
break;
|
||||||
#if LWIP_DHCP_GET_NTP_SRV
|
#if LWIP_DHCP_GET_NTP_SRV
|
||||||
case (DHCP_OPTION_NTP):
|
case (DHCP_OPTION_NTP):
|
||||||
/* special case: there might be more than one server */
|
/* special case: there might be more than one server */
|
||||||
LWIP_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len %% 4 == 0", len % 4 == 0, return ERR_VAL;);
|
||||||
/* limit number of NTP servers */
|
/* limit number of NTP servers */
|
||||||
decode_len = LWIP_MIN(len, 4 * LWIP_DHCP_MAX_NTP_SERVERS);
|
decode_len = LWIP_MIN(len, 4 * LWIP_DHCP_MAX_NTP_SERVERS);
|
||||||
LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_NTP_SERVER;
|
decode_idx = DHCP_OPTION_IDX_NTP_SERVER;
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_DHCP_GET_NTP_SRV*/
|
#endif /* LWIP_DHCP_GET_NTP_SRV*/
|
||||||
case (DHCP_OPTION_OVERLOAD):
|
case (DHCP_OPTION_OVERLOAD):
|
||||||
LWIP_ERROR("len == 1", len == 1, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 1", len == 1, return ERR_VAL;);
|
||||||
/* decode overload only in options, not in file/sname: invalid packet */
|
/* decode overload only in options, not in file/sname: invalid packet */
|
||||||
LWIP_ERROR("overload in file/sname", options_offset == DHCP_OPTIONS_OFS, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("overload in file/sname", options_offset == DHCP_OPTIONS_OFS, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_OVERLOAD;
|
decode_idx = DHCP_OPTION_IDX_OVERLOAD;
|
||||||
break;
|
break;
|
||||||
case (DHCP_OPTION_MESSAGE_TYPE):
|
case (DHCP_OPTION_MESSAGE_TYPE):
|
||||||
LWIP_ERROR("len == 1", len == 1, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 1", len == 1, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_MSG_TYPE;
|
decode_idx = DHCP_OPTION_IDX_MSG_TYPE;
|
||||||
break;
|
break;
|
||||||
case (DHCP_OPTION_SERVER_ID):
|
case (DHCP_OPTION_SERVER_ID):
|
||||||
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 4", len == 4, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_SERVER_ID;
|
decode_idx = DHCP_OPTION_IDX_SERVER_ID;
|
||||||
break;
|
break;
|
||||||
case (DHCP_OPTION_T1):
|
case (DHCP_OPTION_T1):
|
||||||
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 4", len == 4, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_T1;
|
decode_idx = DHCP_OPTION_IDX_T1;
|
||||||
break;
|
break;
|
||||||
case (DHCP_OPTION_T2):
|
case (DHCP_OPTION_T2):
|
||||||
LWIP_ERROR("len == 4", len == 4, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("len == 4", len == 4, return ERR_VAL;);
|
||||||
decode_idx = DHCP_OPTION_IDX_T2;
|
decode_idx = DHCP_OPTION_IDX_T2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1634,7 +1639,7 @@ decode_next:
|
||||||
if (decode_len > 4) {
|
if (decode_len > 4) {
|
||||||
/* decode more than one u32_t */
|
/* decode more than one u32_t */
|
||||||
u16_t next_val_offset;
|
u16_t next_val_offset;
|
||||||
LWIP_ERROR("decode_len %% 4 == 0", decode_len % 4 == 0, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("decode_len %% 4 == 0", decode_len % 4 == 0, return ERR_VAL;);
|
||||||
dhcp_got_option(dhcp, decode_idx);
|
dhcp_got_option(dhcp, decode_idx);
|
||||||
dhcp_set_option_value(dhcp, decode_idx, lwip_htonl(value));
|
dhcp_set_option_value(dhcp, decode_idx, lwip_htonl(value));
|
||||||
decode_len = (u8_t)(decode_len - 4);
|
decode_len = (u8_t)(decode_len - 4);
|
||||||
|
@ -1649,7 +1654,7 @@ decode_next:
|
||||||
} else if (decode_len == 4) {
|
} else if (decode_len == 4) {
|
||||||
value = lwip_ntohl(value);
|
value = lwip_ntohl(value);
|
||||||
} else {
|
} else {
|
||||||
LWIP_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;);
|
||||||
value = ((u8_t *)&value)[0];
|
value = ((u8_t *)&value)[0];
|
||||||
}
|
}
|
||||||
dhcp_got_option(dhcp, decode_idx);
|
dhcp_got_option(dhcp, decode_idx);
|
||||||
|
@ -1662,7 +1667,7 @@ decode_next:
|
||||||
offset_max = (u16_t)(offset_max - q->len);
|
offset_max = (u16_t)(offset_max - q->len);
|
||||||
if (offset < offset_max) {
|
if (offset < offset_max) {
|
||||||
q = q->next;
|
q = q->next;
|
||||||
LWIP_ERROR("next pbuf was null", q != NULL, return ERR_VAL;);
|
LWIP_DHCP_INPUT_ERROR("next pbuf was null", q != NULL, return ERR_VAL;);
|
||||||
options = (u8_t *)q->payload;
|
options = (u8_t *)q->payload;
|
||||||
} else {
|
} else {
|
||||||
/* We've run out of bytes, probably no end marker. Don't proceed. */
|
/* We've run out of bytes, probably no end marker. Don't proceed. */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user