aboutsummaryrefslogtreecommitdiff
path: root/projects/nginx/make_fuzzers
blob: a62d4d6ecc3edefabb0d2694e29f3466eb36cab3 (plain)
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
sed -i 's/main(/fuzz_without_main(/g' src/core/nginx.c

mkdir -p $NGX_OBJS/src/fuzz

ngx_all_objs_fuzz=`echo src/fuzz/wrappers.c $ngx_all_srcs \
    | sed -e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \
          -e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g"`

ngx_deps_fuzz=`echo $ngx_all_objs_fuzz $ngx_modules_obj $ngx_res $LINK_DEPS \
    | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
          -e "s/\//$ngx_regex_dirsep/g"`

ngx_objs=`echo objs/src/fuzz/wrappers.o $ngx_all_objs $ngx_modules_obj \
    | sed -e "s/  *\([^ ][^ ]*\)/$ngx_long_regex_cont\1/g" \
          -e "s/\//$ngx_regex_dirsep/g"`

cat << END                                                    >> $NGX_MAKEFILE

fuzzers: objs/http_request_fuzzer

objs/src/fuzz/wrappers.o:
	\$(CC) $ngx_compile_opt \$(CFLAGS) -o objs/src/fuzz/wrappers.o src/fuzz/wrappers.c

objs/http_request_fuzzer: $ngx_deps_fuzz
	 \$(CXX) \$(CXXFLAGS) src/fuzz/http_request_fuzzer.cc \
	 src/fuzz/genfiles/http_request_proto.pb.cc \
	 -o objs/http_request_fuzzer \
	 \$(CORE_INCS) \$(HTTP_INCS) \
	 -I src/fuzz/genfiles/ -I \$(SRC)/ \
	 -I \$(SRC)/libprotobuf-mutator/ \
	 -I \$(SRC)/LPM/external.protobuf/include \
	 \$(SRC)/LPM/src/libfuzzer/libprotobuf-mutator-libfuzzer.a \
  	 \$(SRC)/LPM/src/libprotobuf-mutator.a \
  	 \$(SRC)/LPM/external.protobuf/lib/libprotobuf.a \
	 $ngx_binexit$ngx_long_cont$ngx_objs \
   	 \$(LIB_FUZZING_ENGINE) $ngx_libs$ngx_link$ngx_main_link -lcrypt
$ngx_long_end					    

END