Compare commits

...
3 Commits
3 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
NDPI_MAJOR="2"
NDPI_MINOR="1"
NDPI_MINOR="2"
NDPI_PATCH="0"
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
+2 -2
View File
@@ -4642,11 +4642,11 @@ static const char* categories[] = {
"Unspecified",
"Media",
"VPN",
"DataTransfer",
"Email",
"Download-FileTransfer-FileSharing",
"DataTransfer",
"Web",
"SocialNetwork",
"Download-FileTransfer-FileSharing",
"Game",
"Chat",
"VoIP",
+14 -7
View File
@@ -70,19 +70,24 @@ 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)
if((packet->payload_packet_len >= 244 /* 244 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))) {
int i = 0, foundValidMsgType = 0;
u_int i = 0, foundValidMsgType = 0;
while(i < DHCP_VEND_LEN) {
u_int dhcp_options_size = ndpi_min(DHCP_VEND_LEN /* maximum size of options in dhcp_packet_t */,
packet->payload_packet_len - 244);
while(i + 1 /* for the len */ < dhcp_options_size) {
u_int8_t id = dhcp->options[i];
if(id == 0xFF)
break;
else {
u_int8_t len = dhcp->options[i+1];
/* Prevent malformed packets to cause out-of-bounds accesses */
u_int8_t len = ndpi_min(dhcp->options[i+1] /* len as found in the packet */,
dhcp_options_size - (i+2) /* 1 for the type and 1 for the value */);
if(len == 0) break;
@@ -98,12 +103,14 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
u_int idx, offset = 0,
hex_len = ndpi_min(len * 2, sizeof(flow->protos.dhcp.fingerprint));
for(idx=0; idx<len; idx++) {
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint)-offset-1,
"%02X", dhcp->options[i+2+idx] & 0xFF);
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%02X", dhcp->options[i+2+idx] & 0xFF);
offset += 2;
}
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
} else if(id == 60 /* Class Identifier */) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;