diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2023-11-07 17:46:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 17:46:29 +0100 |
commit | b539b0d0902bc0fda235d8bbf1bc7f64e9028465 (patch) | |
tree | b4f3e0283cfd2ed757d5721ffb9c6d6862db8597 /src/lib/ndpi_utils.c | |
parent | 58a9e2d9679f268a64b9082dae70498147bb58a8 (diff) |
fuzz: improve coverage and remove dead code (#2135)
We are not able to remove custom rules: remove the empty stubs (which
originate from the original OpenDPI code).
`ndpi_guess_protocol_id()` is only called on the first packet of the
flow, so the bitmask `flow->excluded_protocol_bitmask` is always empty,
since we didn't call any dissectors yet.
Move another hash function to the dedicated source file.
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 68c07fa6c..b41ec6706 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2051,11 +2051,10 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) { case NDPI_TLS_ALPN_SNI_MISMATCH: return("ALPN/SNI Mismatch"); - + case NDPI_MALWARE_HOST_CONTACTED: return("Client contacted a malware host"); - break; - + default: ndpi_snprintf(buf, sizeof(buf), "%d", (int)risk); return(buf); @@ -2201,35 +2200,6 @@ ndpi_http_method ndpi_http_str2method(const char* method, u_int16_t method_len) /* ******************************************************************** */ -#define ROR64(x,r) (((x)>>(r))|((x)<<(64-(r)))) - -/* - 'in_16_bytes_long` points to some 16 byte memory data to be hashed; - two independent 64-bit linear congruential generators are applied - results are mixed, scrambled and cast to 32-bit -*/ -u_int32_t ndpi_quick_16_byte_hash(u_int8_t *in_16_bytes_long) { - u_int64_t a = *(u_int64_t*)(in_16_bytes_long + 0); - u_int64_t c = *(u_int64_t*)(in_16_bytes_long + 8); - - // multipliers are taken from sprng.org, addends are prime - a = a * 0x2c6fe96ee78b6955 + 0x9af64480a3486659; - c = c * 0x369dea0f31a53f85 + 0xd0c6225445b76b5b; - - // mix results - a += c; - - // final scramble - a ^= ROR64(a, 13) ^ ROR64(a, 7); - - // down-casting, also taking advantage of upper half - a ^= a >> 32; - - return((u_int32_t)a); -} - -/* ******************************************************************** */ - int ndpi_hash_init(ndpi_str_hash **h) { if (h == NULL) |