Keep master protocol in ndpi_reconcile_protocols

As a side effect of this change, the following memory leak has been
fixed.
```
==55523==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x55657d01b7be in malloc (/home/ivan/svnrepos/nDPI/fuzz/fuzz_ndpi_reader_alloc_fail+0x5b27be) (BuildId: 9dfa7bd9081421417b8b1c2e8b44633a9bfcfe52)
    #1 0x55657d169182 in ndpi_malloc /home/ivan/svnrepos/nDPI/src/lib/ndpi_main.c:243:25
    #2 0x55657d1694c8 in ndpi_strdup /home/ivan/svnrepos/nDPI/src/lib/ndpi_main.c:310:13
    #3 0x55657d25ddc7 in processClientServerHello /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:2308:46
    #4 0x55657d2701b9 in processTLSBlock /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:895:5
    #5 0x55657d26a408 in ndpi_search_tls_udp /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:1223:11
```

Found by oss-fuzz
See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56466
This commit is contained in:
Nardi Ivan 2023-03-01 19:43:03 +01:00 committed by Ivan Nardi
parent 9eb9664516
commit d65f8cf15f

View file

@ -5948,7 +5948,7 @@ static void ndpi_reconcile_protocols(struct ndpi_detection_module_struct *ndpi_s
case NDPI_PROTOCOL_MS_OUTLOOK:
case NDPI_PROTOCOL_SKYPE_TEAMS:
ndpi_int_change_protocol(ndpi_str, flow,
flow->guessed_protocol_id_by_ip, NDPI_PROTOCOL_UNKNOWN,
flow->guessed_protocol_id_by_ip, flow->detected_protocol_stack[1],
NDPI_CONFIDENCE_DPI_PARTIAL);
break;
}
@ -5959,7 +5959,7 @@ static void ndpi_reconcile_protocols(struct ndpi_detection_module_struct *ndpi_s
switch(flow->guessed_protocol_id_by_ip) {
case NDPI_PROTOCOL_GOOGLE_CLOUD:
ndpi_int_change_protocol(ndpi_str, flow,
flow->guessed_protocol_id_by_ip, NDPI_PROTOCOL_UNKNOWN,
flow->guessed_protocol_id_by_ip, flow->detected_protocol_stack[1],
NDPI_CONFIDENCE_DPI_PARTIAL);
break;