diff --git a/nfstream/engine/engine.py b/nfstream/engine/engine.py index 6caf865..b7dffc2 100644 --- a/nfstream/engine/engine.py +++ b/nfstream/engine/engine.py @@ -520,6 +520,7 @@ typedef enum { struct ndpi_detection_module_struct { NDPI_PROTOCOL_BITMASK detection_bitmask; uint32_t current_ts; + uint16_t max_packets_to_process; uint16_t num_tls_blocks_to_follow; uint8_t skip_tls_blocks_until_change_cipher:1, enable_ja3_plus:1, _notused:6; char custom_category_labels[NUM_CUSTOM_CATEGORIES][CUSTOM_CATEGORY_LABEL_LEN]; diff --git a/nfstream/engine/engine_cc.c b/nfstream/engine/engine_cc.c index 5875cf1..1debf50 100644 --- a/nfstream/engine/engine_cc.c +++ b/nfstream/engine/engine_cc.c @@ -895,6 +895,7 @@ int packet_ether_type_checker(uint32_t caplen, const uint8_t *packet, uint16_t * break; case MPLS_UNI: case MPLS_MULTI: + if (*ip_offset + 4 >= (int) caplen) return 0; mpls.u32 = *((uint32_t *) &packet[(*ip_offset)]); mpls.u32 = ntohl(mpls.u32); (*type) = ETH_P_IP, (*ip_offset) += 4; @@ -1057,11 +1058,12 @@ int packet_process(int datalink_type, uint32_t caplen, uint32_t len, const uint8 tag_len = 1, stop = 1; break; default: + if (offset + 1 >= caplen) return 0; tag_len = packet[offset+1]; break; } offset += tag_len; - if (offset + 1 >= caplen) return 0; + if (offset >= caplen) return 0; else { eth_offset = offset; goto datalink_check;