mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-29 00:32:51 +00:00
dhcp: Fix BOOTP_FILE bug
The comment in dhcp_handle_ack for 'offered_si_addr' states: 'boot file name copied in dhcp_parse_reply if not overloaded' However this code was never reached if the packed was not 'overloaded' Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
parent
d320b27a5f
commit
7d1c6ba549
@ -1512,6 +1512,9 @@ dhcp_parse_reply(struct pbuf *p, struct dhcp *dhcp)
|
|||||||
int parse_file_as_options = 0;
|
int parse_file_as_options = 0;
|
||||||
int parse_sname_as_options = 0;
|
int parse_sname_as_options = 0;
|
||||||
struct dhcp_msg *msg_in;
|
struct dhcp_msg *msg_in;
|
||||||
|
#if LWIP_DHCP_BOOTP_FILE
|
||||||
|
int file_overloaded = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
LWIP_UNUSED_ARG(dhcp);
|
LWIP_UNUSED_ARG(dhcp);
|
||||||
|
|
||||||
@ -1706,25 +1709,15 @@ decode_next:
|
|||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("invalid overload option: %d\n", (int)overload));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("invalid overload option: %d\n", (int)overload));
|
||||||
}
|
}
|
||||||
#if LWIP_DHCP_BOOTP_FILE
|
|
||||||
if (!parse_file_as_options) {
|
|
||||||
/* only do this for ACK messages */
|
|
||||||
if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE) &&
|
|
||||||
(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE) == DHCP_ACK))
|
|
||||||
/* copy bootp file name, don't care for sname (server hostname) */
|
|
||||||
if (pbuf_copy_partial(p, dhcp->boot_file_name, DHCP_FILE_LEN - 1, DHCP_FILE_OFS) != (DHCP_FILE_LEN - 1)) {
|
|
||||||
return ERR_BUF;
|
|
||||||
}
|
|
||||||
/* make sure the string is really NULL-terminated */
|
|
||||||
dhcp->boot_file_name[DHCP_FILE_LEN - 1] = 0;
|
|
||||||
}
|
|
||||||
#endif /* LWIP_DHCP_BOOTP_FILE */
|
|
||||||
}
|
}
|
||||||
if (parse_file_as_options) {
|
if (parse_file_as_options) {
|
||||||
/* if both are overloaded, parse file first and then sname (RFC 2131 ch. 4.1) */
|
/* if both are overloaded, parse file first and then sname (RFC 2131 ch. 4.1) */
|
||||||
parse_file_as_options = 0;
|
parse_file_as_options = 0;
|
||||||
options_idx = DHCP_FILE_OFS;
|
options_idx = DHCP_FILE_OFS;
|
||||||
options_idx_max = DHCP_FILE_OFS + DHCP_FILE_LEN;
|
options_idx_max = DHCP_FILE_OFS + DHCP_FILE_LEN;
|
||||||
|
#if LWIP_DHCP_BOOTP_FILE
|
||||||
|
file_overloaded = 1;
|
||||||
|
#endif
|
||||||
goto again;
|
goto again;
|
||||||
} else if (parse_sname_as_options) {
|
} else if (parse_sname_as_options) {
|
||||||
parse_sname_as_options = 0;
|
parse_sname_as_options = 0;
|
||||||
@ -1732,6 +1725,19 @@ decode_next:
|
|||||||
options_idx_max = DHCP_SNAME_OFS + DHCP_SNAME_LEN;
|
options_idx_max = DHCP_SNAME_OFS + DHCP_SNAME_LEN;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
#if LWIP_DHCP_BOOTP_FILE
|
||||||
|
if (!file_overloaded) {
|
||||||
|
/* only do this for ACK messages */
|
||||||
|
if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_MSG_TYPE) &&
|
||||||
|
(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_MSG_TYPE) == DHCP_ACK))
|
||||||
|
/* copy bootp file name, don't care for sname (server hostname) */
|
||||||
|
if (pbuf_copy_partial(p, dhcp->boot_file_name, DHCP_FILE_LEN-1, DHCP_FILE_OFS) != (DHCP_FILE_LEN-1)) {
|
||||||
|
return ERR_BUF;
|
||||||
|
}
|
||||||
|
/* make sure the string is really NULL-terminated */
|
||||||
|
dhcp->boot_file_name[DHCP_FILE_LEN-1] = 0;
|
||||||
|
}
|
||||||
|
#endif /* LWIP_DHCP_BOOTP_FILE */
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user