From c09b4dacdf179e5f69f2fd72a97b9095881fcc75 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:11:13 +0100 Subject: Fix memory leak (#2340) ``` Direct leak of 12 byte(s) in 1 object(s) allocated from: #0 0x55779e1a46ff in malloc (/home/ivan/svnrepos/nDPI/example/ndpiReader+0x8706ff) (BuildId: 14c2fc626744710d49d652ea1c5bbb24a8cbab4f) #1 0x55779e2120c7 in ndpi_malloc_wrapper /home/ivan/svnrepos/nDPI/example/ndpiReader.c:298:10 #2 0x55779e5fa215 in ndpi_malloc /home/ivan/svnrepos/nDPI/src/lib/ndpi_memory.c:60:25 #3 0x55779e5fa500 in ndpi_strdup /home/ivan/svnrepos/nDPI/src/lib/ndpi_memory.c:113:13 #4 0x55779e42153c in processClientServerHello /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:2554:46 #5 0x55779e4359a1 in processTLSBlock /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:908:5 #6 0x55779e432de7 in ndpi_search_tls_tcp /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:1097:2 #7 0x55779e4133f9 in ndpi_search_tls_wrapper /home/ivan/svnrepos/nDPI/src/lib/protocols/tls.c:2913:5 ``` Found by oss-fuzz See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=67250 --- src/lib/ndpi_main.c | 2 +- src/lib/protocols/tls.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index de3ffec97..878b7ab87 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -7413,7 +7413,7 @@ static void ndpi_reconcile_protocols(struct ndpi_detection_module_struct *ndpi_s } } else if(flow->guessed_protocol_id_by_ip == NDPI_PROTOCOL_TELEGRAM) { ndpi_int_change_protocol(ndpi_str, flow, - flow->guessed_protocol_id_by_ip, flow->detected_protocol_stack[1], + flow->guessed_protocol_id_by_ip, flow->detected_protocol_stack[0], NDPI_CONFIDENCE_DPI_PARTIAL); } break; diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index 65037cfb8..d03860216 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -2615,7 +2615,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct, } #ifdef DEBUG_TLS - printf("Client TLS [SUPPORTED_VERSIONS: %s]\n", ja.client.supported_versions_str); + printf("Client TLS [SUPPORTED_VERSIONS: %s]\n", version_str); #endif if(flow->protos.tls_quic.tls_supported_versions == NULL) -- cgit v1.2.3