aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2024-04-21 12:29:09 +0200
committerNardi Ivan <nardi.ivan@gmail.com>2024-04-21 12:29:09 +0200
commitf494bdd653fcac1bd428bbf39eafd138f6f53d2a (patch)
treeadb98e798d908517b84fbfd38b2b8563f8ad0680 /src
parent246e972f9c1bf2780c348ae43030119ad417c153 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/lib/ndpi_domains.c6
1 files changed, 3 insertions, 3 deletions
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);