From f494bdd653fcac1bd428bbf39eafd138f6f53d2a Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Sun, 21 Apr 2024 12:29:09 +0200 Subject: Fix parameters check ``` ==17==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000546050 bp 0x7fff113c82a0 sp 0x7fff113c7a58 T0) ==17==The signal is caused by a READ memory access. ==17==Hint: address points to the zero page. SCARINESS: 10 (null-deref) #0 0x546050 in __sanitizer::internal_strlen(char const*) /src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp:167:10 #1 0x4c6ba5 in __interceptor_strrchr /src/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:740:5 #2 0x5fb9b9 in ndpi_get_host_domain_suffix /src/ndpi/src/lib/ndpi_domains.c:105:20 #3 0x578058 in LLVMFuzzerTestOneInput /src/ndpi/fuzz/fuzz_config.cpp:503:3 ``` Found while fuzzing --- src/lib/ndpi_domains.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/ndpi_domains.c b/src/lib/ndpi_domains.c index c7f131304..05153d577 100644 --- a/src/lib/ndpi_domains.c +++ b/src/lib/ndpi_domains.c @@ -94,11 +94,11 @@ const char* ndpi_get_host_domain_suffix(struct ndpi_detection_module_struct *ndp u_int16_t *domain_id /* out */) { char *dot, *prev_dot; - *domain_id = 0; - - if(!ndpi_str) + if(!ndpi_str || !hostname || !domain_id) return NULL; + *domain_id = 0; + if(ndpi_str->public_domain_suffixes == NULL) return(hostname); -- cgit v1.2.3