Commit Graph

28 Commits

Author SHA1 Message Date
15ba1db248 Update copyrights 2023-08-31 12:57:30 +02:00
9f30b1a9c5 * fuzz/main.c: Replace VLA 2023-07-29 19:01:29 +02:00
3dc7f71098 Update copyright year 2022-02-25 17:46:43 +01:00
22162f82b2 Update copyright year 2021-01-22 21:58:38 +01:00
59d9ecd9c0 * Update copyright year to 2020 2020-01-10 00:33:02 +01:00
4b9edbad2d Update Copyright statements to be compatible with update-copyright module 2019-09-10 23:41:56 +02:00
12f1a03693 Changed G_GNUC_WGET prefix to WGET_GCC
* include/wget/wget.h: Changed G_GNUC_WGET prefix to WGET_GCC
* */*.[ch]: Likewise
2019-08-08 17:13:24 +02:00
aa2b8f400f Add sc_prohibit_sprintf and sc_prohibit_printf and fix code
* cfg.mk: New syntax rules sc_prohibit_sprintf and sc_prohibit_printf
* fuzz/*.c: Apply rules
* libwget/*.c: Likewise
* src/*.c: Likewise
* tests/*.[ch]: Likewise
* unit-tests/*.c: Likewise
2019-06-17 16:39:24 +02:00
52378f333e * fuzz/main.c: Fix paths for WIN32 2019-05-18 22:32:03 +02:00
cdb3600791 Update copyrigght to 2019 2019-01-02 12:42:53 +01:00
444808c260 Suppress some leaks detected by valgrind in fuzz/
* fuzz/main.c: Use --suppressions and --gen-suppressions
* fuzz/valgrind-suppressions: New suppression file

Some library's memory can't be freed. So we suppress what is needed
to let the CIs survive.
2018-10-19 16:40:09 +02:00
3688ffb941 Update copyright to 2018 2018-04-30 20:52:11 +02:00
af88a7a2c3 Add G_GNUC_WGET_UNUSED to fuzz code
* fuzz/libwget_xml_parse_buffer_fuzzer.c: Likewise
* fuzz/main.c: Likewise
2018-04-30 20:08:06 +02:00
c353a7d121 Exclude fuzz corpora from tarball
* fuzz/Makefile.am: Do not include corpora in tarball
* fuzz/main.c: SKIP if corpora directory isn't found (make check)

The fuzz corpora are thousands of files, not needed for a standard build
from a distribution tarball. The reproducers of former issues are being
included for regression testing.
2018-04-30 19:45:51 +02:00
ce5c9437a6 * fuzz/main.c: Fix path separator on MinGW 2017-12-31 00:10:51 +01:00
f7e4c13099 Add wget_options_fuzzer
* Makefile.am: Fix make target 'fuzz-coverage'
* configure.ac: Enable building static library by default,
  add option --enable-fuzzing
* fuzz/Makefile.am: Add wget_options_fuzzer,
  check for FUZZING (set with --enable-fuzzing)
* fuzz/README.md: Amend the text
* fuzz/main.c: Use printf() instead of wget_info_printf()
* fuzz/run-clang.sh: Use fuzzer binaries built by 'make'
* fuzz/wget_options_fuzzer.c: New fuzzer
* fuzz/wget_options_fuzzer.dict: New fuzzer dictionary
* fuzz/wget_options_fuzzer.in/*: Initial fuzz corpora
* libwget/net.c: Skip IP address resolution when fuzzing
* src/log.c: Don't create files when fuzzing,
  don't print to console when fuzzing
* src/options.c: Add set_exit_status() and get_exit_status(),
  don't print --help / --version to console when fuzzing,
  do not call exit() - return error instead,
  fix recursion level in _read_config(),
  don't create files when fuzzing,
  fix memory leaks in deinit()
* src/stats.c: Don't create files when fuzzing
* src/wget.c: Remove set_exit_status()
* src/wget_main.h: Remove exit_status_t
* src/wget_options.h: Add exit_status_t
* tests/test-plugin.c: Fix expected exit codes from 1 to 2

This is for application fuzzing (namely code from src/).
The code in src/ had to be prepared in certain ways, but it
doesn't add significant overhead, even makes the code cleaner
in some ways. Several of these changes have already been committed
into the master branch.
2017-10-26 15:41:01 +02:00
29e241cad7 Fix usage of wget_global_init() and wget_http_get()
* examples/*.c: Use 0 instead of NULL as terminating param
* fuzz/main.c: Likewise
* include/wget/wget.h: Remove G_GNUC_WGET_NULL_TERMINATED from
  wget_global_init() and wget_http_get().
2017-10-09 16:56:53 +02:00
4c02e13630 Reduce variable scope
* examples/print_html_urls.c: Likewise
* fuzz/libwget_cookie_fuzzer.c: Likewise
* fuzz/main.c: Likewise
* tests/libtest.c: Likewise
* unit-tests/test.c: Likewise

Found by: cppcheck
2017-10-07 13:29:09 +02:00
3b1fe395c8 * fuzz/main.c: Remove libtool prefix 'lt-' from directory names 2017-10-02 21:39:27 +02:00
b3051c7201 Fix fuzzer regression test for WIN32
* fuzz/main.c: Adjust slash and remove .exe

Reported-by: Gisle Vanem
2017-07-25 15:26:27 +02:00
e39040aeb0 Fail fuzzers if *.in directory does not exist
* fuzz/Makefile.am: Set -DTEST_RUN
* fuzz/main.c: Error on non-exisiting *.in directory
2017-07-25 15:14:43 +02:00
00423395c5 Use FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION from oss-fuzz
* fuzz/Makefile.am: Remove -DTEST_RUN from AM_CPPFLAGS
* fuzz/main.c: Use #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
2017-07-14 15:01:48 +02:00
98a8b90f3b Use C instead of C++ for fuzzer targets
* configure.ac: Remove AC_PROG_CXX
* fuzz/Makefile.am: Amend *_SOURCES for .c fuzzer targets,
  Remove non-portable EXTRA_DIST wildcards,
  Add dist-hook to include fuzzer target files,
  Add oss-fuzz make target.
* fuzz/fuzzer.h: New file
* fuzz/*cc: Rename to C, include fuzzer.h
* fuzz/main.c: Include fuzzer.h
* fuzz/run-clang.sh: Build and run fuzzer targets made with clang/libFuzzer
2017-06-08 12:37:28 +02:00
5612f76377 Add OSS-Fuzz reproducers to test suite
* cfg.mk: Exclude *.repro/* from syntax-check
* fuzz/Makefile.am: Add *.repro/* to EXTRA_DIST
* fuzz/libwget_metalink_parse_fuzzer.repro/clusterfuzz-testcase-minimized-5103826937839616:
    Reproducer for OSS-Fuzz issue #1915
* fuzz/libwget_xml_parse_buffer_fuzzer.repro/clusterfuzz-testcase-minimized-4704516446355456:
    Reproducer for OSS-Fuzz issue #2041
* fuzz/main.c: Scan and test all files from *.repro/
2017-06-04 21:10:17 +02:00
68fd51e568 Use fuzz targets as unit tests for 'make check'
* Makefile.am: Add 'fuzz' directory to SUBDIRS,
  tune 'fuzz-coverage' make target,
  print info on how to view coverage report.
* configure.ac: Add AC_PROG_CXX for C++ code in fuzz/
* fuzz/Makefile: Removed
* fuzz/Makefile.am: New file
* fuzz/libwget_bar_fuzzer.cc: Fix memleak
* fuzz/main.c: Add code for unit testing

The OSS-Fuzz targets will now be taken for unit testing as well.

That is, they will be tested by 'make check' including our sanitizer
and valgrind checks. The fuzz tests will be run once with each test
corpus from the corresponding '.in' directory.

A 'make fuzz-coverage' generates a coverage report for running all
fuzz targets against their corpora.
2017-06-02 21:14:45 +02:00
7633bc9810 Add make target 'fuzz-coverage'
* Makefile.am: Add target 'fuzz-coverage' to generate a coverage
  report for fuzz targets.
* fuzz/Makefile: Add target 'fuzz-coverage'
* fuzz/coverage.sh: New script to call a fuzz target with each corpus.
* fuzz/libwget_metalink_parse_fuzzer.cc: Add check for max input length.
* fuzz/libwget_xml_parse_buffer_fuzzer.cc: Likewise
* fuzz/libwget_robots_parse_fuzzer.cc: Add comment
* fuzz/libwget_robots_parse_fuzzer.in/user_agent2: Amend for max coverage
* fuzz/main.c: selfmade __AFL_LOOP() returns 0 after first invocation.
* fuzz/libwget_memtohex.in: Rename to fuzz/libwget_memtohex_fuzzer.in
* fuzz/libwget_metalink_parse.in: Rename to fuzz/libwget_metalink_parse_fuzzer.in
* fuzz/libwget_robots_parse.in: Rename to fuzz/libwget_robots_parse_fuzzer.in
* fuzz/libwget_xml_parse_buffer.in: Rename to fuzz/libwget_xml_parse_buffer_fuzzer.in
* fuzz/libwget_xml_parse_buffer.options: Removed
* fuzz/libwget_metalink_parse_fuzzer.options: Removed
2017-06-01 17:06:57 +02:00
ab1803f91c Enhance fuzz code
* fuzz/*_fuzzer.cc: Use malloc() instead of stack memory to help
  sanitizers.
* fuzz/libwget_robots_parse.in/user_agent1: Increase code coverage.
* fuzz/main.c: define __AFL_LOOP() is not already defined.
2017-05-31 17:06:22 +02:00
8e2fecc6ff Add initial fuzzing code
* fuzz/*: New files

README.md contains instructions how to build and run single fuzzers.
Currently we have fuzzers and corpora for
  - wget_memtohex()
  - wget_metalink_parse()
  - wget_robots_parse()
  - wget_xml_parse_buffer()

* fuzz/libwget_bar.in/123456: New file
2017-05-29 10:10:47 +02:00