Files
url.c/tests/build_afl.sh
T
Claude bd0a0f0c26 Add comprehensive fuzzing infrastructure for URL parser
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
2025-12-06 15:23:32 +00:00

45 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Build script for AFL++ fuzzing
#
# Prerequisites:
# - AFL++ installed (https://github.com/AFLplusplus/AFLplusplus)
#
# Install AFL++ on Ubuntu/Debian:
# sudo apt-get install afl++
#
# Or build from source:
# git clone https://github.com/AFLplusplus/AFLplusplus
# cd AFLplusplus
# make
# sudo make install
set -e
echo "Building fuzz target with AFL++..."
# Try different AFL++ compilers in order of preference
if command -v afl-clang-fast &> /dev/null; then
echo "Using afl-clang-fast (recommended)"
AFL_CC=afl-clang-fast
elif command -v afl-gcc &> /dev/null; then
echo "Using afl-gcc"
AFL_CC=afl-gcc
elif command -v afl-clang &> /dev/null; then
echo "Using afl-clang"
AFL_CC=afl-clang
else
echo "Error: No AFL++ compiler found!"
echo "Please install AFL++ first:"
echo " sudo apt-get install afl++"
echo "Or see: https://github.com/AFLplusplus/AFLplusplus"
exit 1
fi
# Build the fuzz target
$AFL_CC -o fuzz_afl fuzz_afl.c ../url.c -Wall -Wextra -ggdb
echo "Build successful! Binary: fuzz_afl"
echo ""
echo "To run fuzzing:"
echo " ./run_afl.sh"