diff options
author | Denys Vlasenko | 2021-09-02 14:40:54 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-09-02 14:40:54 +0200 |
commit | 62d0c8e02872d444ba20b4bdf638ac26c509a3dd (patch) | |
tree | 1c7b9da0053ae54b7ab7fdeb18b7cccdf7ff3356 /networking/udhcp | |
parent | d99dee944eabab5184c356027b0a7a9dd9e2541a (diff) | |
download | busybox-62d0c8e02872d444ba20b4bdf638ac26c509a3dd.zip busybox-62d0c8e02872d444ba20b4bdf638ac26c509a3dd.tar.gz |
udhcpd: check config file for bad IP ranges (start > end)
function old new delta
.rodata 104209 104238 +29
read_config 208 225 +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 46/0) Total: 46 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/dhcpd.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index eef8a3b..b67dfc3 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -451,6 +451,8 @@ static NOINLINE void read_config(const char *file) server_data.start_ip = ntohl(server_data.start_ip); server_data.end_ip = ntohl(server_data.end_ip); + if (server_data.start_ip > server_data.end_ip) + bb_error_msg_and_die("bad start/end IP range in %s", file); } static void write_leases(void) @@ -858,7 +860,6 @@ int udhcpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int udhcpd_main(int argc UNUSED_PARAM, char **argv) { int server_socket = -1, retval; - uint8_t *state; unsigned timeout_end; unsigned num_ips; unsigned opt; @@ -966,6 +967,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) struct dhcp_packet packet; int bytes; int tv; + uint8_t *msg_type; uint8_t *server_id_opt; uint8_t *requested_ip_opt; uint32_t requested_nip; @@ -1040,8 +1042,8 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) bb_info_msg("not a REQUEST%s", ", ignoring packet"); continue; } - state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); - if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) { + msg_type = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); + if (!msg_type || msg_type[0] < DHCP_MINTYPE || msg_type[0] > DHCP_MAXTYPE) { bb_info_msg("no or bad message type option%s", ", ignoring packet"); continue; } @@ -1077,7 +1079,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) move_from_unaligned32(requested_nip, requested_ip_opt); } - switch (state[0]) { + switch (msg_type[0]) { case DHCPDISCOVER: log1("received %s", "DISCOVER"); |