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
This commit is contained in:
Nardi Ivan
2024-04-21 12:29:09 +02:00
parent 246e972f9c
commit f494bdd653
+3 -3
View File
@@ -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);