diff options
author | Luca Deri <deri@ntop.org> | 2020-08-04 21:59:45 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-08-04 21:59:45 +0200 |
commit | 00b27633999ce2a439101ff1e00261cfc8e072ae (patch) | |
tree | 9dc08ad20fd5f9a7c01d469b77f47f8bb2b7842a /src | |
parent | e16675b7008191157d86dd7752b0a9e529315171 (diff) |
Added check on payload lenght during extra packet processing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/protocols/http.c | 10 | ||||
-rw-r--r-- | src/lib/protocols/telnet.c | 6 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c index 2b96e55b4..eb64265ee 100644 --- a/src/lib/protocols/http.c +++ b/src/lib/protocols/http.c @@ -71,6 +71,7 @@ static void ndpi_analyze_content_signature(struct ndpi_flow_struct *flow) { static int ndpi_search_http_tcp_again(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { + ndpi_search_http_tcp(ndpi_struct, flow); #ifdef HTTP_DEBUG @@ -133,7 +134,7 @@ static ndpi_protocol_category_t ndpi_http_check_content(struct ndpi_detection_mo } /* check for attachment */ - if (packet->content_disposition_line.len > 0) { + if(packet->content_disposition_line.len > 0) { u_int8_t attachment_len = sizeof("attachment; filename"); if(packet->content_disposition_line.len > attachment_len) { @@ -224,7 +225,7 @@ static void rtsp_parse_packet_acceptline(struct ndpi_detection_module_struct static void setHttpUserAgent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, char *ua) { - if ( !strcmp(ua, "Windows NT 5.0")) ua = "Windows 2000"; + if( !strcmp(ua, "Windows NT 5.0")) ua = "Windows 2000"; else if(!strcmp(ua, "Windows NT 5.1")) ua = "Windows XP"; else if(!strcmp(ua, "Windows NT 5.2")) ua = "Windows Server 2003"; else if(!strcmp(ua, "Windows NT 6.0")) ua = "Windows Vista"; @@ -741,7 +742,8 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct packet->packet_lines_parsed_complete = 0; /* Check if we so far detected the protocol in the request or not. */ - if(flow->l4.tcp.http_stage == 0) { + if((packet->payload_packet_len > 0) /* Needed in case of extra packet processing */ + && (flow->l4.tcp.http_stage == 0)) { /* Expected a request */ flow->http_detected = 0; @@ -823,7 +825,7 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct /* try to get some additional request header info even if the packet may not be HTTP */ ndpi_parse_packet_line_info(ndpi_struct, flow); - if (packet->http_num_headers > 0) { + if(packet->http_num_headers > 0) { check_content_type_and_change_protocol(ndpi_struct, flow); return; } diff --git a/src/lib/protocols/telnet.c b/src/lib/protocols/telnet.c index 8e688eca0..bc3211f3d 100644 --- a/src/lib/protocols/telnet.c +++ b/src/lib/protocols/telnet.c @@ -42,9 +42,9 @@ static int search_telnet_again(struct ndpi_detection_module_struct *ndpi_struct, printf("==> %s() [%s][direction: %u]\n", __FUNCTION__, packet->payload, packet->packet_direction); #endif - if (packet->payload == NULL || packet->payload_packet_len == 0) - return(1); - if(packet->payload[0] == 0xFF) + if((packet->payload == NULL) + || (packet->payload_packet_len == 0) + || (packet->payload[0] == 0xFF)) return(1); if(flow->protos.telnet.username_detected) { |