This commit adds AFL++ (American Fuzzy Lop) fuzzing support to help find bugs, crashes, and security vulnerabilities in the URL parser. Changes: - Add fuzz_afl.c: AFL++ fuzz target that tests all parser functions - url_parse() with different flag combinations - url_parse_ipv4() and url_parse_ipv6() - url_serialize(), url_percent_decode(), url_remove_white_space() - Add build_afl.sh: Build script with AFL++ compiler detection - Add run_afl.sh: Automated fuzzing script with result reporting - Add url.dict: Dictionary file to guide AFL++ mutations - Add corpus/: Seed inputs covering various URL patterns - Basic URLs, IPv4/IPv6, percent-encoding, relative paths - Edge cases and special schemes (file://, mailto:, etc.) - Add FUZZING.md: Comprehensive documentation - Installation instructions - Quick start guide - Advanced usage (parallel fuzzing, sanitizers) - Troubleshooting tips - Add fuzz.c: Standalone mutation-based fuzzer (no AFL++ required) - Useful for quick testing without installing AFL++ - Implements various mutation strategies
url.c
This is a small library to parse and manipulate URLs in conformance to RFC 3986 and WHATWG.
It features
- No allocations
- No dependencies
- The ability to switch between RFC 3986 and WHATWG with a flag
- Relative reference parsing and resolution
- URL normalization
- Doesn't rely on null-terminated strings
Usage
You just copy paste url.h and url.c in your source tree and compile them as usual.
Some example programs are provided in the examples/ folder. To compile them, run build.bat on Windows or build.sh on Linux.
Testing
The parser and reference resolver is tested against the URL section of the web platform tests. Note that not all tests pass. This is due to the parser not doing any normalization and not supporting more niche features such as converting \ characters to / or supporting drive letters like C: in the URL's path.
To run the test suite, cd into tests/ and compile the test runner using build.sh (Linux) or build.bat (Windows). Then, run ./test.out (Linux) or ./test.exe (Windows).