diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2023-02-09 20:02:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-09 20:02:12 +0100 |
commit | b51a2ac72a3cbd1b470890d0151a46da28e6754e (patch) | |
tree | 694a86ec7690962b21fb2c1bcf12df9f842d5957 /example/reader_util.c | |
parent | 4bb851384efb2a321def0bdb5e93786fac1cc02b (diff) |
fuzz: some improvements and add two new fuzzers (#1881)
Remove `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` define from
`fuzz/Makefile.am`; it is already included by the main configure script
(when fuzzing).
Add a knob to force disabling of AESNI optimizations: this way we can
fuzz also no-aesni crypto code.
Move CRC32 algorithm into the library.
Add some fake traces to extend fuzzing coverage. Note that these traces
are hand-made (via scapy/curl) and must not be used as "proof" that the
dissectors are really able to identify this kind of traffic.
Some small updates to some dissectors:
CSGO: remove a wrong rule (never triggered, BTW). Any UDP packet starting
with "VS01" will be classified as STEAM (see steam.c around line 111).
Googling it, it seems right so.
XBOX: XBOX only analyses UDP flows while HTTP only TCP ones; therefore
that condition is false.
RTP, STUN: removed useless "break"s
Zattoo: `flow->zattoo_stage` is never set to any values greater or equal
to 5, so these checks are never true.
PPStream: `flow->l4.udp.ppstream_stage` is never read. Delete it.
TeamSpeak: we check for `flow->packet_counter == 3` just above, so the
following check `flow->packet_counter >= 3` is always false.
Diffstat (limited to 'example/reader_util.c')
-rw-r--r-- | example/reader_util.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/example/reader_util.c b/example/reader_util.c index 62fa3046a..b1f72c650 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -2253,55 +2253,6 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow, flow_risk)); } -/* ********************************************************** */ -/* http://home.thep.lu.se/~bjorn/crc/crc32_fast.c */ -/* ********************************************************** */ - -static uint32_t crc32_for_byte(uint32_t r) { - int j; - for(j = 0; j < 8; ++j) - r = ((r & 1) ? 0 : (uint32_t)0xEDB88320L) ^ r >> 1; - return r ^ (uint32_t)0xFF000000L; -} - -/* Any unsigned integer type with at least 32 bits may be used as - * accumulator type for fast crc32-calulation, but unsigned long is - * probably the optimal choice for most systems. */ -typedef unsigned long accum_t; - -static void init_tables(uint32_t* table, uint32_t* wtable) { - size_t i, j, k, w; - for(i = 0; i < 0x100; ++i) - table[i] = crc32_for_byte(i); - for(k = 0; k < sizeof(accum_t); ++k) - for(i = 0; i < 0x100; ++i) { - for(j = w = 0; j < sizeof(accum_t); ++j) - w = table[(uint8_t)(j == k? w ^ i: w)] ^ w >> 8; - wtable[(k << 8) + i] = w ^ (k? wtable[0]: 0); - } -} - -static void __crc32(const void* data, size_t n_bytes, uint32_t* crc) { - static uint32_t table[0x100], wtable[0x100*sizeof(accum_t)]; - size_t n_accum = n_bytes/sizeof(accum_t); - size_t i, j; - if(!*table) - init_tables(table, wtable); - for(i = 0; i < n_accum; ++i) { - accum_t a = *crc ^ ((accum_t*)data)[i]; - for(j = *crc = 0; j < sizeof(accum_t); ++j) - *crc ^= wtable[(j << 8) + (uint8_t)(a >> 8*j)]; - } - for(i = n_accum*sizeof(accum_t); i < n_bytes; ++i) - *crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8; -} - -u_int32_t ethernet_crc32(const void* data, size_t n_bytes) { - u_int32_t crc = 0; - __crc32(data, n_bytes, &crc); - return crc; -} - /* *********************************************** */ #ifdef USE_DPDK |