Added memory checks
This commit is contained in:
@@ -80,11 +80,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
|
||||
r = pcap_next_ex(pkts, &header, &pkt);
|
||||
while (r > 0) {
|
||||
if(header->caplen >= 42 /* ARP+ size */) {
|
||||
/* allocate an exact size buffer to check overflows */
|
||||
uint8_t *packet_checked = malloc(header->caplen);
|
||||
|
||||
if(packet_checked) {
|
||||
memcpy(packet_checked, pkt, header->caplen);
|
||||
ndpi_workflow_process_packet(workflow, header, packet_checked, NULL);
|
||||
free(packet_checked);
|
||||
}
|
||||
}
|
||||
|
||||
r = pcap_next_ex(pkts, &header, &pkt);
|
||||
}
|
||||
ndpi_workflow_free(workflow);
|
||||
|
||||
@@ -114,7 +114,7 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
quic_hlen++;
|
||||
}
|
||||
|
||||
if(udp_len > quic_hlen + 16 + 4) {
|
||||
if(udp_len > (quic_hlen + 16 + 4)) {
|
||||
if(!strncmp((char*)&packet->payload[quic_hlen+16], "CHLO" /* Client Hello */, 4)) {
|
||||
/* Check if SNI (Server Name Identification) is present */
|
||||
for(i=quic_hlen+12; i<udp_len-3; i++) {
|
||||
@@ -129,10 +129,11 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t len = offset - prev_offset;
|
||||
u_int32_t sni_offset = i+prev_offset+1;
|
||||
|
||||
if(len < udp_len) {
|
||||
while((sni_offset < udp_len) && (packet->payload[sni_offset] == '-'))
|
||||
sni_offset++;
|
||||
|
||||
if(len > 0 && (sni_offset+len) < udp_len) {
|
||||
if((sni_offset+len) < udp_len) {
|
||||
u_int32_t max_len = sizeof(flow->host_server_name)-1, j = 0;
|
||||
ndpi_protocol_match_result ret_match;
|
||||
|
||||
@@ -156,6 +157,7 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -479,7 +479,8 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
|
||||
}
|
||||
}
|
||||
|
||||
if(rdn_len) flow->protos.stun_ssl.ssl.subjectDN = ndpi_strdup(rdnSeqBuf);
|
||||
if(rdn_len && (flow->protos.stun_ssl.ssl.subjectDN == NULL))
|
||||
flow->protos.stun_ssl.ssl.subjectDN = ndpi_strdup(rdnSeqBuf);
|
||||
|
||||
if(flow->protos.stun_ssl.ssl.subjectDN && flow->protos.stun_ssl.ssl.issuerDN
|
||||
&& (!strcmp(flow->protos.stun_ssl.ssl.subjectDN, flow->protos.stun_ssl.ssl.issuerDN)))
|
||||
|
||||
Reference in New Issue
Block a user