The hand-written Makefiles compiled objects with a rule of the form
"%.o: %.c $(HEADERS)" where $(HEADERS) was a hand-maintained list. That list
missed transitive headers, third_party/include/*.h, the generated *.c.inc
files, and the ndpi-pro/nDPI-custom protocol snippets that tls.c #includes, so
editing any of those did not trigger a rebuild.
Replace it with automatic dependency tracking: compile with -MMD -MP so the
compiler writes an exact .d fragment per object, and read those back with
-include $(wildcard *.d). -MP emits phony targets for each header so a removed
header does not break the build. The explicit $(HEADERS) list is dropped
(kept only the generated-header ordering for the first compile); .d files are
removed by "make clean" and ignored via *.d in .gitignore.
Applied to src/lib, src/lib/plugins, example, tests/unit and tests/dga; the
automake-generated Makefiles already do this.
Also fix a typo that made --with-ndpi-pro a no-op: the AS_IF tested
${with_npri_pro} instead of ${with_ndpi_pro}, so CUSTOM_NDPI /
-DCUSTOM_NDPI_PROTOCOLS was never set.
* WIP
* Fix compilation of fuzzing
* Fix fuzzing compilation
* Cleaned up old quic contributed code (#3222)
Recode commits 713cdd0, 26df140
* QUIC: refactoring
* WIP
* WIP
* Revert "QUIC: refactoring"
This reverts commit 50afd07f28.
* QUIC: refactoring original Wireshark code (#3224)
* Added ability to specify in protocol definition, when a (partial) protocol
can change. This can be queries using a new APi call
named ndpi_can_partial_proto_classification_change()
* TLS: minor changes and remove same stale comments
* Fix out-of-bounds read of TLS certificate dates (#3225)
notBefore and notAfter are u_int32_t, but ndpi_tls2json() passed their
address to ndpi_gmtime_r() as a time_t *. Wherever time_t is 8 bytes this
reads 4 bytes past the field, picking up the adjacent member, so the value
handed to gmtime_r() is notBefore | (notAfter << 32) on little-endian.
gmtime_r() then fails on that out-of-range value and returns NULL, leaving
before/after NULL, so the "notbefore" and "notafter" fields are silently
dropped from the JSON output. On architectures that require aligned access
the 8-byte load traps instead of merely being wrong.
Convert to a real time_t instead of casting the address. The temporaries
are named not_before/not_after because notBefore/notAfter are already
char[32] buffers in the same function.
* WIP
* fuzz: fix compilation
---------
Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
Co-authored-by: Luca Deri <deri@ntop.org>
Co-authored-by: shalseth <33956011+shalseth@users.noreply.github.com>
Internal tests take a non-negligible duration: run them only once in CI.
This way, CI is faster.
To manually run them, use `ndpiReader --run-tests`; note that this way
the application runs ONLY these tests.
ndpiReader was setting custom memory allocation hooks only inside
test_lib(), which is executed after several code paths that already
use nDPI APIs (e.g., parseOptions, help/extcap paths, host checks,
DoH initialization, etc.).
This could lead to inconsistent allocator usage where memory is
allocated using the default libc allocator (when hooks are unset)
and later freed using custom allocators, resulting in undefined
behavior with non-trivial allocators.
This partially addresses #1280.
Put all the internal unit tests in a separate file.
The tests suite run (via `ndpiReader`):
* if the option `--run-tests` is used,
* always if the library is compiled with `-DNDPI_EXTENDED_SANITY_CHECKS`
(useful in CI)
Extend tests using part of #3146.
We keep `tests/unit/unit.c` for serialization tests, like now, because
that is the only code that depends on the external library libjson-c