From f40aaaf3690b418caa80f66a73706f2502199c43 Mon Sep 17 00:00:00 2001 From: candybit <76103388+candybit@users.noreply.github.com> Date: Sat, 19 Dec 2020 11:38:44 +0000 Subject: [PATCH] Fix bad DHCP options offset (#1091) --- src/lib/protocols/dhcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/protocols/dhcp.c b/src/lib/protocols/dhcp.c index 5bf2a122c..0409ec1e2 100644 --- a/src/lib/protocols/dhcp.c +++ b/src/lib/protocols/dhcp.c @@ -70,14 +70,14 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru if(packet->udp) { dhcp_packet_t *dhcp = (dhcp_packet_t*)packet->payload; - if((packet->payload_packet_len >= 244 /* 244 is the offset of options[0] in dhcp_packet_t */) + if((packet->payload_packet_len >= 240 /* 240 is the offset of options[0] in dhcp_packet_t */) && (packet->udp->source == htons(67) || packet->udp->source == htons(68)) && (packet->udp->dest == htons(67) || packet->udp->dest == htons(68)) && (dhcp->magic == htonl(DHCP_OPTION_MAGIC_NUMBER))) { u_int i = 0, foundValidMsgType = 0; u_int dhcp_options_size = ndpi_min(DHCP_VEND_LEN /* maximum size of options in dhcp_packet_t */, - packet->payload_packet_len - 244); + packet->payload_packet_len - 240); while(i + 1 /* for the len */ < dhcp_options_size) { u_int8_t id = dhcp->options[i];