From f3dcae88dc2ac7cdd38f23d3ffa3a814f71ef925 Mon Sep 17 00:00:00 2001 From: Ivan Nardi Date: Mon, 3 Mar 2025 12:47:46 +0100 Subject: Address cache: fix a use-of-uninitialized-value error on cache restore ``` ==29602==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x563af77d47ac in ndpi_address_cache_restore /home/ivan/svnrepos/nDPI/src/lib/ndpi_cache.c:450:8 #1 0x563af77d6b52 in ndpi_cache_address_restore /home/ivan/svnrepos/nDPI/src/lib/ndpi_cache.c:518:10 #2 0x563af77c73e5 in LLVMFuzzerTestOneInput /home/ivan/svnrepos/nDPI/fuzz/fuzz_ds_address_cache.cpp:100:5 ``` Found by oss-fuzz. See: https://oss-fuzz.com/testcase-detail/6653546833707008 --- src/lib/ndpi_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/ndpi_cache.c b/src/lib/ndpi_cache.c index c4e25ffea..b97bbcff3 100644 --- a/src/lib/ndpi_cache.c +++ b/src/lib/ndpi_cache.c @@ -446,7 +446,7 @@ u_int32_t ndpi_address_cache_restore(struct ndpi_address_cache *cache, char *pat if(!fd) return(false); - while(fscanf(fd, "%32s\t%255s\t%u\n", ip, hostname, &epoch) > 0) { + while(fscanf(fd, "%32s\t%255s\t%u\n", ip, hostname, &epoch) == 3) { if(epoch >= epoch_now) { /* Entry not yet expired */ u_int ttl = epoch-epoch_now; ndpi_ip_addr_t addr; -- cgit v1.2.3