From f6c400a98aa19e345da931c63204b39237904fff Mon Sep 17 00:00:00 2001 From: lucaderi Date: Tue, 27 Sep 2016 08:01:15 +0200 Subject: [PATCH] Fix for #249 (not sure is enough) --- example/ndpiReader.c | 2 +- src/lib/ndpi_main.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/example/ndpiReader.c b/example/ndpiReader.c index c52e0334990a..deb61b681a79 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -1080,7 +1080,7 @@ static void configurePcapHandle(pcap_t * pcap_handle) { */ static pcap_t * openPcapFileOrDevice(u_int16_t thread_id, const u_char * pcap_file) { - u_int snaplen = 65535; + u_int snaplen = 1536; int promisc = 1; char pcap_error_buffer[PCAP_ERRBUF_SIZE]; pcap_t * pcap_handle = NULL; diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index c07920ae1d98..c9ead2f61bb4 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -3711,7 +3711,7 @@ void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struc packet->line[packet->parsed_lines].ptr = packet->payload; packet->line[packet->parsed_lines].len = 0; - for(a = 0; a < end; a++) { + for(a = 0; a < end-1 /* This because get_u_int16_t(packet->payload, a) reads 2 bytes */; a++) { if(get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) { packet->line[packet->parsed_lines].len = (u_int16_t)(((unsigned long) &packet->payload[a]) - ((unsigned long) packet->line[packet->parsed_lines].ptr)); @@ -3764,10 +3764,8 @@ void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struc } if(packet->line[packet->parsed_lines].len > 14 - && - (memcmp - (packet->line[packet->parsed_lines].ptr, "Content-Type: ", - 14) == 0 || memcmp(packet->line[packet->parsed_lines].ptr, "Content-type: ", 14) == 0)) { + && (memcmp(packet->line[packet->parsed_lines].ptr, "Content-Type: ", 14) == 0 + || memcmp(packet->line[packet->parsed_lines].ptr, "Content-type: ", 14) == 0)) { packet->content_line.ptr = &packet->line[packet->parsed_lines].ptr[14]; packet->content_line.len = packet->line[packet->parsed_lines].len - 14; } @@ -3845,7 +3843,6 @@ void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struc packet->line[packet->parsed_lines].len = 0; if((a + 2) >= packet->payload_packet_len) { - return; } a++;