Fix possible crash due to unsigned int number wrapping

This commit is contained in:
emanuele-f
2019-11-11 10:18:55 +01:00
parent 8181d63a95
commit 748f10c0d6
+5 -5
View File
@@ -765,6 +765,11 @@ int getSSCertificateFingerprint(struct ndpi_detection_module_struct *ndpi_struct
else if(flow->l4.tcp.tls_srv_cert_fingerprint_processed) else if(flow->l4.tcp.tls_srv_cert_fingerprint_processed)
return(0); /* We're good */ return(0); /* We're good */
if(packet->payload_packet_len <= flow->l4.tcp.tls_record_offset) {
/* Avoid invalid memory accesses */
return(1);
}
if(flow->l4.tcp.tls_fingerprint_len > 0) { if(flow->l4.tcp.tls_fingerprint_len > 0) {
unsigned int avail = packet->payload_packet_len - flow->l4.tcp.tls_record_offset; unsigned int avail = packet->payload_packet_len - flow->l4.tcp.tls_record_offset;
@@ -817,11 +822,6 @@ int getSSCertificateFingerprint(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
if(packet->payload_packet_len <= flow->l4.tcp.tls_record_offset) {
/* Avoid invalid memory accesses */
return(1);
}
if(packet->payload[flow->l4.tcp.tls_record_offset] == 0x15 /* Alert */) { if(packet->payload[flow->l4.tcp.tls_record_offset] == 0x15 /* Alert */) {
u_int len = ntohs(*(u_int16_t*)&packet->payload[flow->l4.tcp.tls_record_offset+3]) + 5 /* SSL header len */; u_int len = ntohs(*(u_int16_t*)&packet->payload[flow->l4.tcp.tls_record_offset+3]) + 5 /* SSL header len */;