mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-12-05 22:18:27 +00:00
* Add chunked_decoder_fuzzer and a seed corpus for multipart_parser_fuzzer * Apply clang-format to chunked_decoder_fuzzer.cc * Simplify chunked_decoder_fuzzer and tidy the seed corpora read_content_chunked() only touches the trailers and headers, which Request and Response share, so decoding into both ran the same code. Decode into a Response only. Drop the SIZE_MAX limit as well: fuzz inputs never get near the 100MB default, so both take the same branches. Adjust the first byte of the chunked seeds to the new selector, and remove the seed for SIZE_MAX. Drop the duplicated number prefixes from the multipart seed names, run both new corpora from the "all" target, and keep the fuzzer rules in the order of FUZZERS. --------- Co-authored-by: Sai Viswas Basetti <saiviswasbasettitw@gmail.com> Co-authored-by: yhirose <yuji.hirose.bug@gmail.com>
61 lines
3.0 KiB
Makefile
61 lines
3.0 KiB
Makefile
|
|
#CXX = clang++
|
|
# Do not add default sanitizer flags here as OSS-fuzz adds its own sanitizer flags.
|
|
CXXFLAGS += -ggdb -O0 -std=c++11 -DGTEST_USE_OWN_TR1_TUPLE -I../.. -I. -Wall -Wextra -Wtype-limits -Wconversion
|
|
|
|
OPENSSL_DIR = /usr/local/opt/openssl@1.1
|
|
|
|
# Using full path to libssl and libcrypto to avoid accidentally picking openssl libs brought in by msan.
|
|
OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -I$(OPENSSL_DIR)/lib /usr/local/lib/libssl.a /usr/local/lib/libcrypto.a
|
|
|
|
ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz
|
|
|
|
BROTLI_DIR = /usr/local/opt/brotli
|
|
# BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec
|
|
|
|
FUZZERS = server_fuzzer url_parser_fuzzer header_parser_fuzzer client_fuzzer multipart_parser_fuzzer websocket_fuzzer sse_parser_fuzzer server_mount_fuzzer chunked_decoder_fuzzer
|
|
|
|
# Runs all the tests and also fuzz tests against seed corpus.
|
|
all : $(FUZZERS)
|
|
./server_fuzzer corpus/*
|
|
./server_mount_fuzzer corpus_mount/*
|
|
./multipart_parser_fuzzer corpus_multipart/*
|
|
./chunked_decoder_fuzzer corpus_chunked/*
|
|
|
|
# Fuzz target, so that you can choose which $(LIB_FUZZING_ENGINE) to use.
|
|
server_fuzzer : server_fuzzer.cc fuzzed_stream.h ../../httplib.h
|
|
# $(CXX) $(CXXFLAGS) -o $@ $< -Wl,-Bstatic $(OPENSSL_SUPPORT) -Wl,-Bdynamic -ldl $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
zip -q -r server_fuzzer_seed_corpus.zip corpus
|
|
|
|
client_fuzzer : client_fuzzer.cc ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
zip -q -r client_fuzzer_seed_corpus.zip corpus
|
|
|
|
header_parser_fuzzer : header_parser_fuzzer.cc ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
|
|
url_parser_fuzzer : url_parser_fuzzer.cc ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
|
|
multipart_parser_fuzzer : multipart_parser_fuzzer.cc ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
zip -q -r multipart_parser_fuzzer_seed_corpus.zip corpus_multipart
|
|
|
|
websocket_fuzzer : websocket_fuzzer.cc ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
|
|
sse_parser_fuzzer : sse_parser_fuzzer.cc ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
|
|
server_mount_fuzzer : server_mount_fuzzer.cc fuzzed_stream.h ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
zip -q -r server_mount_fuzzer_seed_corpus.zip corpus_mount
|
|
|
|
chunked_decoder_fuzzer : chunked_decoder_fuzzer.cc fuzzed_stream.h ../../httplib.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< $(ZLIB_SUPPORT) $(LIB_FUZZING_ENGINE) -pthread -lanl
|
|
zip -q -r chunked_decoder_fuzzer_seed_corpus.zip corpus_chunked
|
|
|
|
clean:
|
|
rm -f server_fuzzer pem *.0 *.o *.1 *.srl *.zip
|