fix dhcp buffer overflow
This commit is contained in:
+20
-19
@@ -78,34 +78,35 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
|
|||||||
|
|
||||||
while(i < DHCP_VEND_LEN) {
|
while(i < DHCP_VEND_LEN) {
|
||||||
u_int8_t id = dhcp->options[i];
|
u_int8_t id = dhcp->options[i];
|
||||||
u_int8_t len = dhcp->options[i+1];
|
if(id == 0xFF) break;
|
||||||
|
else {
|
||||||
|
u_int8_t len = dhcp->options[i+1];
|
||||||
|
|
||||||
if(len == 0) break;
|
if(len == 0) break;
|
||||||
|
|
||||||
#ifdef DHCP_DEBUG
|
#ifdef DHCP_DEBUG
|
||||||
printf("[DHCP] Id=%d [len=%d]\n", id, len);
|
printf("[DHCP] Id=%d [len=%d]\n", id, len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(id == 53 /* DHCP Message Type */) {
|
if(id == 53 /* DHCP Message Type */) {
|
||||||
u_int8_t msg_type = dhcp->options[i+2];
|
u_int8_t msg_type = dhcp->options[i+2];
|
||||||
|
|
||||||
if(msg_type <= 8) foundValidMsgType = 1;
|
if(msg_type <= 8) foundValidMsgType = 1;
|
||||||
} else if(id == 12 /* Host Name */) {
|
} else if(id == 12 /* Host Name */) {
|
||||||
char *name = (char*)&dhcp->options[i+2];
|
char *name = (char*)&dhcp->options[i+2];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
#ifdef DHCP_DEBUG
|
#ifdef DHCP_DEBUG
|
||||||
printf("[DHCP] ");
|
printf("[DHCP] ");
|
||||||
while(j < len) { printf("%c", name[j]); j++; }
|
while(j < len) { printf("%c", name[j]); j++; }
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
|
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
|
||||||
strncpy((char*)flow->host_server_name, name, j);
|
strncpy((char*)flow->host_server_name, name, j);
|
||||||
flow->host_server_name[j] = '\0';
|
flow->host_server_name[j] = '\0';
|
||||||
} else if(id == 0xFF)
|
}
|
||||||
break;
|
i += len + 2;
|
||||||
|
}
|
||||||
i += len + 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
|
//get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user