@@ -8,13 +8,15 @@ PHP_ARG_ENABLE([fuzzer],
88dnl  For newer Clang versions see https://llvm.org/docs/LibFuzzer.html#fuzzer-usage
99dnl  for relevant flags.
1010
11- dnl  Macro to define fuzzing target 
11+ dnl 
1212dnl  PHP_FUZZER_TARGET(name, target-var)
1313dnl 
14+ dnl  Macro to define the fuzzing target.
15+ dnl 
1416AC_DEFUN ( [ PHP_FUZZER_TARGET]  , [ 
1517  PHP_FUZZER_BINARIES="$PHP_FUZZER_BINARIES $SAPI_FUZZER_PATH/php-fuzz-$1 " 
1618  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 ]  ) 
1820  $2 ="[ $] $2  $FUZZER_COMMON_OBJS" 
1921] ) 
2022
@@ -30,19 +32,18 @@ if test "$PHP_FUZZER" != "no"; then
3032  PHP_ADD_MAKEFILE_FRAGMENT([ $abs_srcdir/sapi/fuzzer/Makefile.frag]  )
3133  SAPI_FUZZER_PATH=sapi/fuzzer
3234  PHP_SUBST([ SAPI_FUZZER_PATH]  )
33-   if test -z "$ LIB_FUZZING_ENGINE"; then 
35+   AS_VAR_IF ( [ LIB_FUZZING_ENGINE] ,,  [ 
3436    FUZZING_LIB="-fsanitize=fuzzer" 
35-     FUZZING_CC=" $CC" 
37+     FUZZING_CC=$CC 
3638    AX_CHECK_COMPILE_FLAG ( [ -fsanitize=fuzzer-no-link]  , [  
3739      CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link" 
3840      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 
4445    FUZZING_CC="$CXX -stdlib=libc++" 
45-   fi 
46+   ]  ) 
4647  PHP_SUBST([ FUZZING_LIB]  )
4748  PHP_SUBST([ FUZZING_CC]  )
4849
@@ -55,21 +56,21 @@ if test "$PHP_FUZZER" != "no"; then
5556
5657  PHP_ADD_SOURCES_X([ sapi/fuzzer]  , [ fuzzer-sapi.c]  , [ ]  , [ FUZZER_COMMON_OBJS]  )
5758
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]  )
6566
6667  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]  )
6869  fi
6970  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]  )
7172    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]  )
7374    fi
7475  fi
7576
0 commit comments