@@ -8,13 +8,15 @@ PHP_ARG_ENABLE([fuzzer],
8
8
dnl For newer Clang versions see https://llvm.org/docs/LibFuzzer.html#fuzzer-usage
9
9
dnl for relevant flags.
10
10
11
- dnl Macro to define fuzzing target
11
+ dnl
12
12
dnl PHP_FUZZER_TARGET(name, target-var)
13
13
dnl
14
+ dnl Macro to define the fuzzing target.
15
+ dnl
14
16
AC_DEFUN ( [ PHP_FUZZER_TARGET] , [
15
17
PHP_FUZZER_BINARIES="$PHP_FUZZER_BINARIES $SAPI_FUZZER_PATH/php-fuzz-$1 "
16
18
PHP_SUBST([ $2 ] )
17
- PHP_ADD_SOURCES_X([ sapi/fuzzer] ,[ fuzzer-$1 .c] ,[ ] ,$2 )
19
+ PHP_ADD_SOURCES_X([ sapi/fuzzer] , [ fuzzer-$1 .c] , [ ] , [ $2 ] )
18
20
$2 ="[ $] $2 $FUZZER_COMMON_OBJS"
19
21
] )
20
22
@@ -30,19 +32,18 @@ if test "$PHP_FUZZER" != "no"; then
30
32
PHP_ADD_MAKEFILE_FRAGMENT([ $abs_srcdir/sapi/fuzzer/Makefile.frag] )
31
33
SAPI_FUZZER_PATH=sapi/fuzzer
32
34
PHP_SUBST([ SAPI_FUZZER_PATH] )
33
- if test -z "$ LIB_FUZZING_ENGINE"; then
35
+ AS_VAR_IF ( [ LIB_FUZZING_ENGINE] ,, [
34
36
FUZZING_LIB="-fsanitize=fuzzer"
35
- FUZZING_CC=" $CC"
37
+ FUZZING_CC=$CC
36
38
AX_CHECK_COMPILE_FLAG ( [ -fsanitize=fuzzer-no-link] , [
37
39
CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
38
40
CXXFLAGS="$CXXFLAGS -fsanitize=fuzzer-no-link"
39
- ] ,[
40
- AC_MSG_ERROR ( [ Compiler doesn't support -fsanitize=fuzzer-no-link] )
41
- ] )
42
- else
43
- FUZZING_LIB="$LIB_FUZZING_ENGINE"
41
+ ] ,
42
+ [ AC_MSG_ERROR ( [ Compiler doesn't support -fsanitize=fuzzer-no-link] ) ] )
43
+ ] , [
44
+ FUZZING_LIB=$LIB_FUZZING_ENGINE
44
45
FUZZING_CC="$CXX -stdlib=libc++"
45
- fi
46
+ ] )
46
47
PHP_SUBST([ FUZZING_LIB] )
47
48
PHP_SUBST([ FUZZING_CC] )
48
49
@@ -55,21 +56,21 @@ if test "$PHP_FUZZER" != "no"; then
55
56
56
57
PHP_ADD_SOURCES_X([ sapi/fuzzer] , [ fuzzer-sapi.c] , [ ] , [ FUZZER_COMMON_OBJS] )
57
58
58
- PHP_FUZZER_TARGET([ parser] , PHP_FUZZER_PARSER_OBJS)
59
- PHP_FUZZER_TARGET([ execute] , PHP_FUZZER_EXECUTE_OBJS)
60
- PHP_FUZZER_TARGET([ function-jit] , PHP_FUZZER_FUNCTION_JIT_OBJS)
61
- PHP_FUZZER_TARGET([ tracing-jit] , PHP_FUZZER_TRACING_JIT_OBJS)
62
- PHP_FUZZER_TARGET([ unserialize] , PHP_FUZZER_UNSERIALIZE_OBJS)
63
- PHP_FUZZER_TARGET([ unserializehash] , PHP_FUZZER_UNSERIALIZEHASH_OBJS)
64
- PHP_FUZZER_TARGET([ json] , PHP_FUZZER_JSON_OBJS)
59
+ PHP_FUZZER_TARGET([ parser] , [ PHP_FUZZER_PARSER_OBJS] )
60
+ PHP_FUZZER_TARGET([ execute] , [ PHP_FUZZER_EXECUTE_OBJS] )
61
+ PHP_FUZZER_TARGET([ function-jit] , [ PHP_FUZZER_FUNCTION_JIT_OBJS] )
62
+ PHP_FUZZER_TARGET([ tracing-jit] , [ PHP_FUZZER_TRACING_JIT_OBJS] )
63
+ PHP_FUZZER_TARGET([ unserialize] , [ PHP_FUZZER_UNSERIALIZE_OBJS] )
64
+ PHP_FUZZER_TARGET([ unserializehash] , [ PHP_FUZZER_UNSERIALIZEHASH_OBJS] )
65
+ PHP_FUZZER_TARGET([ json] , [ PHP_FUZZER_JSON_OBJS] )
65
66
66
67
if test -n "$enable_exif" && test "$enable_exif" != "no"; then
67
- PHP_FUZZER_TARGET([ exif] , PHP_FUZZER_EXIF_OBJS)
68
+ PHP_FUZZER_TARGET([ exif] , [ PHP_FUZZER_EXIF_OBJS] )
68
69
fi
69
70
if test -n "$enable_mbstring" && test "$enable_mbstring" != "no"; then
70
- PHP_FUZZER_TARGET([ mbstring] , PHP_FUZZER_MBSTRING_OBJS)
71
+ PHP_FUZZER_TARGET([ mbstring] , [ PHP_FUZZER_MBSTRING_OBJS] )
71
72
if test -n "$enable_mbregex" && test "$enable_mbregex" != "no"; then
72
- PHP_FUZZER_TARGET([ mbregex] , PHP_FUZZER_MBREGEX_OBJS)
73
+ PHP_FUZZER_TARGET([ mbregex] , [ PHP_FUZZER_MBREGEX_OBJS] )
73
74
fi
74
75
fi
75
76
0 commit comments