mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-26 21:04:25 +08:00
fuzz: Use libFuzzer instead of afl-fuzz
This allows us to have faster fuzz cycles since the fuzzer is in-process.
This commit is contained in:
parent
e748f435e5
commit
00ef791078
11
Makefile
11
Makefile
@ -68,10 +68,9 @@ test: $(EXECUTABLE)
|
|||||||
./$(EXECUTABLE)
|
./$(EXECUTABLE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fuzz:
|
fuzz_%: $(BUILD)/fuzz_%
|
||||||
@mkdir -p $(BUILD)
|
@mkdir -p build/$@
|
||||||
$(AFL)/afl-clang++ tests/fuzz_parse.cpp tests/allocator.cpp src/pugixml.cpp $(CXXFLAGS) -o $(BUILD)/fuzz_parse
|
$< build/$@ tests/data_$*
|
||||||
$(AFL)/afl-fuzz -i tests/data_fuzz_parse -o $(BUILD)/fuzz_parse_out -x $(AFL)/testcases/_extras/xml/ -- $(BUILD)/fuzz_parse @@
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD)
|
rm -rf $(BUILD)
|
||||||
@ -87,6 +86,10 @@ build/pugixml-%: .FORCE | $(RELEASE)
|
|||||||
$(EXECUTABLE): $(OBJECTS)
|
$(EXECUTABLE): $(OBJECTS)
|
||||||
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
|
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
$(BUILD)/fuzz_%: tests/fuzz_%.cpp src/pugixml.cpp
|
||||||
|
@mkdir -p $(BUILD)
|
||||||
|
clang++ $(CXXFLAGS) -fsanitize=address -fsanitize-coverage=trace-pc-guard $^ libFuzzer.a -o $@
|
||||||
|
|
||||||
$(BUILD)/%.o: %
|
$(BUILD)/%.o: %
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CXX) $< $(CXXFLAGS) -c -MMD -MP -o $@
|
$(CXX) $< $(CXXFLAGS) -c -MMD -MP -o $@
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#include "../src/pugixml.hpp"
|
#include "../src/pugixml.hpp"
|
||||||
#include "allocator.hpp"
|
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
||||||
{
|
{
|
||||||
pugi::set_memory_management_functions(memory_allocate, memory_deallocate);
|
|
||||||
|
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i)
|
doc.load_buffer(Data, Size);
|
||||||
{
|
doc.load_buffer(Data, Size, pugi::parse_minimal);
|
||||||
doc.load_file(argv[i]);
|
doc.load_buffer(Data, Size, pugi::parse_full);
|
||||||
doc.load_file(argv[i], pugi::parse_minimal);
|
|
||||||
doc.load_file(argv[i], pugi::parse_full);
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user