-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.fuzz
72 lines (57 loc) · 2.16 KB
/
Makefile.fuzz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# To run xpath fuzzer:
# make -f Makefile.fuzz fuzz-xpath DYLD_LIBRARY_PATH=/path/to/build/products
# make -f Makefile.fuzz fuzz-xslt DYLD_LIBRARY_PATH=/path/to/build/products
# To merge a corpus:
# make -f Makefile.fuzz merge-corpus DYLD_LIBRARY_PATH=/path/to/build/products
#
# To build dylib with fuzzing enabled (for use with libxslt fuzzers):
# make -f Makefile.fuzz dylib
fuzz_dir = ./libxslt/tests/fuzz
top_srcdir = ./..
XCODEBUILD_FUZZER_FLAGS = ENABLE_LIBFUZZER=YES ENABLE_ADDRESS_SANITIZER=YES ENABLE_UNDEFINED_BEHAVIOR_SANITIZER=YES
.PHONY: $(fuzz_dir)/xpath $(fuzz_dir)/xslt
all: xpath xslt
xpath: $(fuzz_dir)/xpath
$(fuzz_dir)/xpath: $(fuzz_dir)/xpath.c $(fuzz_dir)/fuzz.c
rm -f $(fuzz_dir)/fuzz-xpath $(fuzz_dir)/xpath
xcodebuild -target fuzz-xpath -configuration Debug $(XCODEBUILD_FUZZER_FLAGS)
mv -f $(fuzz_dir)/fuzz-xpath $(fuzz_dir)/xpath
xslt: $(fuzz_dir)/xslt
$(fuzz_dir)/xslt: $(fuzz_dir)/xslt.c $(fuzz_dir)/fuzz.c
rm -f $(fuzz_dir)/fuzz-xslt $(fuzz_dir)/xslt
xcodebuild -target fuzz-xslt -configuration Debug $(XCODEBUILD_FUZZER_FLAGS)
mv -f $(fuzz_dir)/fuzz-xslt $(fuzz_dir)/xslt
.PHONY: corpus clean-corpus merge-corpus
clean-corpus:
rm -rf $(fuzz_dir)/corpus/xpath
rm -rf $(fuzz_dir)/corpus/xslt
merge-%-corpus: %
cd $(fuzz_dir); \
for D in $^; do \
echo "Merging corpus/$$D..." && \
mkdir corpus/$$D-merge && \
DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH) ./$$D corpus/$$D-merge corpus/$$D -merge=1 && \
mv corpus/$$D corpus/$$D-old && \
mv corpus/$$D-merge corpus/$$D && \
echo "Before/after merge: " && \
du -sh corpus/$$D-old corpus/$$D && \
rm -rf corpus/$$D-old; \
done
merge-corpus: merge-xpath-corpus merge-xslt-corpus
# XPath fuzzer
fuzz-xpath: $(fuzz_dir)/xpath
cd $(fuzz_dir); \
mkdir -p corpus/xpath; \
DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH) ./xpath \
-dict=xpath.dict \
-max_len=256 \
corpus/xpath seed/xpath
# XSLT fuzzer
fuzz-xslt: $(fuzz_dir)/xslt
cd $(fuzz_dir); \
mkdir -p corpus/xslt; \
DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH) ./xslt \
-dict=xslt.dict \
corpus/xslt seed/xslt
dylib:
xcodebuild -target All -configuration Debug $(XCODEBUILD_FUZZER_FLAGS)