Additional memory bounds checks
This commit is contained in:
+3
-1
@@ -4252,6 +4252,8 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
|
|||||||
if(flow->host_server_name[0] != '\0') {
|
if(flow->host_server_name[0] != '\0') {
|
||||||
ndpi_protocol_match_result ret_match;
|
ndpi_protocol_match_result ret_match;
|
||||||
|
|
||||||
|
memset(&ret_match, 0, sizeof(ret_match));
|
||||||
|
|
||||||
ndpi_match_host_subprotocol(ndpi_str, flow,
|
ndpi_match_host_subprotocol(ndpi_str, flow,
|
||||||
(char *)flow->host_server_name,
|
(char *)flow->host_server_name,
|
||||||
strlen((const char*)flow->host_server_name),
|
strlen((const char*)flow->host_server_name),
|
||||||
@@ -5096,7 +5098,7 @@ void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
|
|
||||||
for(a = 0; (a < packet->payload_packet_len)
|
for(a = 0; (a < packet->payload_packet_len)
|
||||||
&& (packet->parsed_lines < NDPI_MAX_PARSE_LINES_PER_PACKET); a++) {
|
&& (packet->parsed_lines < NDPI_MAX_PARSE_LINES_PER_PACKET); a++) {
|
||||||
if((a + 1) == packet->payload_packet_len)
|
if((a + 1) >= packet->payload_packet_len)
|
||||||
return; /* Return if only one byte remains (prevent invalid reads past end-of-buffer) */
|
return; /* Return if only one byte remains (prevent invalid reads past end-of-buffer) */
|
||||||
|
|
||||||
if(get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) { /* If end of line char sequence CR+NL "\r\n", process line */
|
if(get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) { /* If end of line char sequence CR+NL "\r\n", process line */
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
|
|||||||
packet->parsed_lines = 0;
|
packet->parsed_lines = 0;
|
||||||
}
|
}
|
||||||
for (i = 0; i < packet->parsed_lines; i++) {
|
for (i = 0; i < packet->parsed_lines; i++) {
|
||||||
if (packet->line[i].ptr[0] == ':') {
|
if ((packet->line[i].len > 0) && packet->line[i].ptr[0] == ':') {
|
||||||
flow->l4.tcp.irc_3a_counter++;
|
flow->l4.tcp.irc_3a_counter++;
|
||||||
if (flow->l4.tcp.irc_3a_counter == 7) { /* ':' == 0x3a */
|
if (flow->l4.tcp.irc_3a_counter == 7) { /* ':' == 0x3a */
|
||||||
NDPI_LOG_INFO(ndpi_struct, "found irc. 0x3a. seven times.");
|
NDPI_LOG_INFO(ndpi_struct, "found irc. 0x3a. seven times.");
|
||||||
|
|||||||
@@ -874,7 +874,7 @@ int getSSCertificateFingerprint(struct ndpi_detection_module_struct *ndpi_struct
|
|||||||
return(0); /* That's all */
|
return(0); /* That's all */
|
||||||
} else if(flow->l4.tcp.tls_seen_certificate)
|
} else if(flow->l4.tcp.tls_seen_certificate)
|
||||||
return(0); /* That's all */
|
return(0); /* That's all */
|
||||||
else if(packet->payload_packet_len > flow->l4.tcp.tls_record_offset+7) {
|
else if(packet->payload_packet_len > flow->l4.tcp.tls_record_offset+7+1/* +1 because we are going to read 2 bytes */) {
|
||||||
/* This is a handshake but not a certificate record */
|
/* This is a handshake but not a certificate record */
|
||||||
u_int16_t len = ntohs(*(u_int16_t*)&packet->payload[flow->l4.tcp.tls_record_offset+7]);
|
u_int16_t len = ntohs(*(u_int16_t*)&packet->payload[flow->l4.tcp.tls_record_offset+7]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user