4 Commits

Author SHA1 Message Date
Petr Štetiar
ab4c3471b2 tests: add cram based unit tests
For the start with cgi-exec testing.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-10-27 23:03:04 +01:00
Petr Štetiar
09f9ac5066 Fix off-by-one in postdecode_fields
Fixes following error found by fuzzer:

 ERROR: AddressSanitizer: SEGV on unknown address 0x60c000120000 (pc 0x00000054f64f bp 0x000000000008 sp 0x7ffe4fc2c120 T0)
 The signal is caused by a READ memory access.
    #0 0x54f64f in postdecode_fields cgi-io/util.c:93:7
    #1 0x54f382 in LLVMFuzzerTestOneInput cgi-io/tests/fuzz/test-fuzz.c:36:6

That is caused by reading 1 byte past the size of the buffer.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-10-27 23:03:04 +01:00
Petr Štetiar
ed8ce0d5d2 Add fuzzing of utility functions
Thus increase fuzzing coverage.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-10-27 23:03:04 +01:00
Petr Štetiar
a615818198 Add fuzzing of multipart_parser
LibFuzzer is in-process, coverage-guided, evolutionary fuzzing engine.

LibFuzzer is linked with the library under test, and feeds fuzzed inputs to
the library via a specific fuzzing entrypoint (aka "target function"); the
fuzzer then tracks which areas of the code are reached, and generates
mutations on the corpus of input data in order to maximize the code coverage.

Lets use libFuzzer to fuzz multipart_parser for the start.

Ref: https://llvm.org/docs/LibFuzzer.html
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2020-10-27 23:03:04 +01:00