Makefile.am (18675B)
1 # This Makefile.am is in the public domain 2 3 # In-process fuzzing harnesses. See README in this directory. 4 # 5 # The harnesses are built only with --enable-fuzzing (see 6 # BUILD-INTEGRATION.md). They are ordinary check_PROGRAMS with a 7 # built-in deterministic driver, so they need neither clang nor 8 # libFuzzer nor AFL++; with those available the very same sources are 9 # compiled into libFuzzer/AFL++ targets by contrib/oss-fuzz/build.sh. 10 11 SUBDIRS = . 12 13 # Number of generate/mutate iterations per harness during "make check". 14 # Raise for a real fuzzing session, e.g. 15 # make LE_FUZZ_ITERATIONS=1000000 LE_FUZZ_SEED=42 check 16 LE_FUZZ_ITERATIONS = 20000 17 18 # PRNG seed; every run is exactly reproducible from (harness, seed). 19 LE_FUZZ_SEED = 1 20 21 # Where reproducers for failing inputs are written. 22 LE_FUZZ_CRASH_DIR = crashes 23 24 # Set to 1 to also flag string metadata that is not 0-terminated. Off by 25 # default: it is a contract violation rather than a memory error, and it 26 # is common enough in the older plugins to drown everything else. 27 LE_FUZZ_STRICT_PROC = 0 28 29 AM_CPPFLAGS = \ 30 -I$(top_srcdir)/src/include \ 31 -I$(top_srcdir)/src/common \ 32 -I$(top_srcdir)/src/main \ 33 -I$(top_srcdir)/src/fuzz 34 35 AM_TESTS_ENVIRONMENT = \ 36 LE_FUZZ_ITERATIONS="$(LE_FUZZ_ITERATIONS)" ; \ 37 export LE_FUZZ_ITERATIONS ; \ 38 LE_FUZZ_SEED="$(LE_FUZZ_SEED)" ; export LE_FUZZ_SEED ; \ 39 LE_FUZZ_CRASH_DIR="$(LE_FUZZ_CRASH_DIR)" ; \ 40 export LE_FUZZ_CRASH_DIR ; \ 41 LE_FUZZ_STRICT_PROC="$(LE_FUZZ_STRICT_PROC)" ; \ 42 export LE_FUZZ_STRICT_PROC ; \ 43 LIBEXTRACTOR_PREFIX="$(abs_top_builddir)/src/plugins/.libs" ; \ 44 export LIBEXTRACTOR_PREFIX ; 45 46 if USE_COVERAGE 47 AM_CFLAGS = --coverage -O0 48 XLIB = -lgcov 49 endif 50 51 # fuzz_datasource, fuzz_unzip and fuzz_ipc call functions that are 52 # internal to the library and are therefore hidden in the shared object; 53 # they are linked against the static archives, which requires 54 # --enable-static (the default). 55 LE_LIB = $(top_builddir)/src/main/libextractor.la 56 LE_COMMON = $(top_builddir)/src/common/libextractor_common.la 57 58 noinst_HEADERS = \ 59 fuzz_common.h \ 60 fuzz_ec.h \ 61 fuzz_plugin_name.h 62 63 EXTRA_DIST = \ 64 README \ 65 BUILD-INTEGRATION.md \ 66 CAMPAIGN.md \ 67 corpus 68 69 CLEANFILES = \ 70 $(LE_FUZZ_CRASH_DIR)/*.bin 71 72 73 # --------------------------------------------------------------------- 74 # Core harnesses 75 # --------------------------------------------------------------------- 76 77 CORE_FUZZERS = \ 78 fuzz_extract \ 79 fuzz_datasource \ 80 fuzz_ipc \ 81 fuzz_convert 82 83 fuzz_extract_SOURCES = fuzz_extract.c 84 fuzz_extract_LDADD = $(LE_LIB) $(XLIB) 85 86 fuzz_datasource_SOURCES = fuzz_datasource.c 87 fuzz_datasource_LDFLAGS = -static 88 fuzz_datasource_LDADD = $(LE_LIB) $(XLIB) 89 90 fuzz_ipc_SOURCES = fuzz_ipc.c 91 fuzz_ipc_LDFLAGS = -static 92 fuzz_ipc_LDADD = $(LE_LIB) $(XLIB) 93 94 fuzz_convert_SOURCES = fuzz_convert.c 95 fuzz_convert_LDFLAGS = -static 96 fuzz_convert_LDADD = $(LE_COMMON) $(LE_LIB) $(XLIB) 97 98 if HAVE_ZLIB 99 UNZIP_FUZZER = fuzz_unzip 100 fuzz_unzip_SOURCES = fuzz_unzip.c 101 fuzz_unzip_LDFLAGS = -static 102 fuzz_unzip_LDADD = $(LE_COMMON) $(XLIB) -lz 103 endif 104 105 106 # --------------------------------------------------------------------- 107 # Per-plugin harnesses 108 # 109 # Each of these compiles fuzz_plugin.c against the plugin's own sources, 110 # so the parser is instrumented and no dlopen()/fork() is involved. The 111 # two -D flags are described in fuzz_plugin_name.h. 112 # --------------------------------------------------------------------- 113 114 PLUGIN_DIR = $(top_srcdir)/src/plugins 115 116 # Plugins that are always built: pure in-tree parsers with no external 117 # dependency. These are where libextractor's own bugs live. 118 PLAIN_PLUGIN_FUZZERS = \ 119 fuzz_applefile \ 120 fuzz_dvi \ 121 fuzz_elf \ 122 fuzz_it \ 123 fuzz_man \ 124 fuzz_nsf \ 125 fuzz_nsfe \ 126 fuzz_ps \ 127 fuzz_real \ 128 fuzz_riff \ 129 fuzz_rtf \ 130 fuzz_s3m \ 131 fuzz_sid \ 132 fuzz_wav \ 133 fuzz_xm \ 134 fuzz_pecoff \ 135 fuzz_lnk \ 136 fuzz_sqlite \ 137 fuzz_tar \ 138 fuzz_iso9660 \ 139 fuzz_diskimage \ 140 fuzz_heif \ 141 fuzz_webp \ 142 fuzz_plist \ 143 fuzz_id3 \ 144 fuzz_gpx \ 145 fuzz_kml \ 146 fuzz_geotiff \ 147 fuzz_mbox 148 149 fuzz_applefile_SOURCES = fuzz_plugin.c 150 fuzz_applefile_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 151 -DLE_FUZZ_PLUGIN=applefile -DLE_FUZZ_ID=APPLEFILE 152 fuzz_applefile_LDADD = $(XLIB) 153 nodist_fuzz_applefile_SOURCES = \ 154 $(PLUGIN_DIR)/applefile_extractor.c $(PLUGIN_DIR)/pack.c 155 156 fuzz_dvi_SOURCES = fuzz_plugin.c 157 fuzz_dvi_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 158 -DLE_FUZZ_PLUGIN=dvi -DLE_FUZZ_ID=DVI 159 fuzz_dvi_LDADD = $(XLIB) $(SOCKET_LIBS) 160 nodist_fuzz_dvi_SOURCES = $(PLUGIN_DIR)/dvi_extractor.c 161 162 fuzz_elf_SOURCES = fuzz_plugin.c 163 fuzz_elf_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 164 -DLE_FUZZ_PLUGIN=elf -DLE_FUZZ_ID=ELF 165 fuzz_elf_LDADD = $(XLIB) $(SOCKET_LIBS) 166 nodist_fuzz_elf_SOURCES = \ 167 $(PLUGIN_DIR)/elf_extractor.c $(PLUGIN_DIR)/pack.c 168 169 fuzz_it_SOURCES = fuzz_plugin.c 170 fuzz_it_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 171 -DLE_FUZZ_PLUGIN=it -DLE_FUZZ_ID=IT 172 fuzz_it_LDADD = $(XLIB) 173 nodist_fuzz_it_SOURCES = $(PLUGIN_DIR)/it_extractor.c 174 175 fuzz_man_SOURCES = fuzz_plugin.c 176 fuzz_man_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 177 -DLE_FUZZ_PLUGIN=man -DLE_FUZZ_ID=MAN 178 fuzz_man_LDADD = $(XLIB) 179 nodist_fuzz_man_SOURCES = $(PLUGIN_DIR)/man_extractor.c 180 181 fuzz_nsf_SOURCES = fuzz_plugin.c 182 fuzz_nsf_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 183 -DLE_FUZZ_PLUGIN=nsf -DLE_FUZZ_ID=NSF 184 fuzz_nsf_LDADD = $(XLIB) 185 nodist_fuzz_nsf_SOURCES = $(PLUGIN_DIR)/nsf_extractor.c 186 187 fuzz_nsfe_SOURCES = fuzz_plugin.c 188 fuzz_nsfe_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 189 -DLE_FUZZ_PLUGIN=nsfe -DLE_FUZZ_ID=NSFE 190 fuzz_nsfe_LDFLAGS = -static 191 fuzz_nsfe_LDADD = $(LE_COMMON) $(XLIB) 192 nodist_fuzz_nsfe_SOURCES = $(PLUGIN_DIR)/nsfe_extractor.c 193 194 fuzz_ps_SOURCES = fuzz_plugin.c 195 fuzz_ps_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 196 -DLE_FUZZ_PLUGIN=ps -DLE_FUZZ_ID=PS 197 fuzz_ps_LDADD = $(XLIB) 198 nodist_fuzz_ps_SOURCES = $(PLUGIN_DIR)/ps_extractor.c 199 200 fuzz_real_SOURCES = fuzz_plugin.c 201 fuzz_real_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 202 -DLE_FUZZ_PLUGIN=real -DLE_FUZZ_ID=REAL 203 fuzz_real_LDADD = $(XLIB) 204 nodist_fuzz_real_SOURCES = $(PLUGIN_DIR)/real_extractor.c 205 206 fuzz_riff_SOURCES = fuzz_plugin.c 207 fuzz_riff_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 208 -DLE_FUZZ_PLUGIN=riff -DLE_FUZZ_ID=RIFF 209 fuzz_riff_LDADD = $(XLIB) -lm 210 nodist_fuzz_riff_SOURCES = $(PLUGIN_DIR)/riff_extractor.c 211 212 fuzz_rtf_SOURCES = fuzz_plugin.c 213 fuzz_rtf_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 214 -DLE_FUZZ_PLUGIN=rtf -DLE_FUZZ_ID=RTF 215 fuzz_rtf_LDFLAGS = -static 216 fuzz_rtf_LDADD = $(LE_COMMON) $(XLIB) 217 nodist_fuzz_rtf_SOURCES = $(PLUGIN_DIR)/rtf_extractor.c 218 219 fuzz_s3m_SOURCES = fuzz_plugin.c 220 fuzz_s3m_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 221 -DLE_FUZZ_PLUGIN=s3m -DLE_FUZZ_ID=S3M 222 fuzz_s3m_LDADD = $(XLIB) 223 nodist_fuzz_s3m_SOURCES = $(PLUGIN_DIR)/s3m_extractor.c 224 225 fuzz_sid_SOURCES = fuzz_plugin.c 226 fuzz_sid_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 227 -DLE_FUZZ_PLUGIN=sid -DLE_FUZZ_ID=SID 228 fuzz_sid_LDADD = $(XLIB) 229 nodist_fuzz_sid_SOURCES = $(PLUGIN_DIR)/sid_extractor.c 230 231 fuzz_wav_SOURCES = fuzz_plugin.c 232 fuzz_wav_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 233 -DLE_FUZZ_PLUGIN=wav -DLE_FUZZ_ID=WAV 234 fuzz_wav_LDADD = $(XLIB) 235 nodist_fuzz_wav_SOURCES = $(PLUGIN_DIR)/wav_extractor.c 236 237 fuzz_xm_SOURCES = fuzz_plugin.c 238 fuzz_xm_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 239 -DLE_FUZZ_PLUGIN=xm -DLE_FUZZ_ID=XM 240 fuzz_xm_LDADD = $(XLIB) 241 nodist_fuzz_xm_SOURCES = $(PLUGIN_DIR)/xm_extractor.c 242 243 244 # Plugins that need zlib; these are the container formats, and the ZIP 245 # based ones share src/common/unzip.c. 246 if HAVE_ZLIB 247 ZLIB_PLUGIN_FUZZERS = \ 248 fuzz_deb \ 249 fuzz_msoffice \ 250 fuzz_odf \ 251 fuzz_png \ 252 fuzz_qt \ 253 fuzz_zip \ 254 fuzz_apk \ 255 fuzz_ebook 256 257 # The forensic header parsers. They share forensics.c, so it is 258 # compiled into every one of these harnesses. 259 fuzz_pecoff_SOURCES = fuzz_plugin.c 260 fuzz_pecoff_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 261 -DLE_FUZZ_PLUGIN=pecoff -DLE_FUZZ_ID=PECOFF 262 fuzz_pecoff_LDADD = $(XLIB) -lm 263 nodist_fuzz_pecoff_SOURCES = \ 264 $(PLUGIN_DIR)/pecoff_extractor.c \ 265 $(PLUGIN_DIR)/forensics.c 266 267 fuzz_lnk_SOURCES = fuzz_plugin.c 268 fuzz_lnk_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 269 -DLE_FUZZ_PLUGIN=lnk -DLE_FUZZ_ID=LNK 270 fuzz_lnk_LDADD = $(XLIB) -lm 271 nodist_fuzz_lnk_SOURCES = \ 272 $(PLUGIN_DIR)/lnk_extractor.c \ 273 $(PLUGIN_DIR)/forensics.c 274 275 fuzz_sqlite_SOURCES = fuzz_plugin.c 276 fuzz_sqlite_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 277 -DLE_FUZZ_PLUGIN=sqlite -DLE_FUZZ_ID=SQLITE 278 fuzz_sqlite_LDADD = $(XLIB) -lm 279 nodist_fuzz_sqlite_SOURCES = \ 280 $(PLUGIN_DIR)/sqlite_extractor.c \ 281 $(PLUGIN_DIR)/forensics.c 282 283 fuzz_tar_SOURCES = fuzz_plugin.c 284 fuzz_tar_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 285 -DLE_FUZZ_PLUGIN=tar -DLE_FUZZ_ID=TAR 286 fuzz_tar_LDADD = $(XLIB) -lm 287 nodist_fuzz_tar_SOURCES = \ 288 $(PLUGIN_DIR)/tar_extractor.c \ 289 $(PLUGIN_DIR)/forensics.c 290 291 fuzz_iso9660_SOURCES = fuzz_plugin.c 292 fuzz_iso9660_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 293 -DLE_FUZZ_PLUGIN=iso9660 -DLE_FUZZ_ID=ISO9660 294 fuzz_iso9660_LDADD = $(XLIB) -lm 295 nodist_fuzz_iso9660_SOURCES = \ 296 $(PLUGIN_DIR)/iso9660_extractor.c \ 297 $(PLUGIN_DIR)/forensics.c 298 299 fuzz_diskimage_SOURCES = fuzz_plugin.c 300 fuzz_diskimage_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 301 -DLE_FUZZ_PLUGIN=diskimage -DLE_FUZZ_ID=DISKIMAGE 302 fuzz_diskimage_LDADD = $(XLIB) -lm 303 nodist_fuzz_diskimage_SOURCES = \ 304 $(PLUGIN_DIR)/diskimage_extractor.c \ 305 $(PLUGIN_DIR)/forensics.c 306 307 fuzz_heif_SOURCES = fuzz_plugin.c 308 fuzz_heif_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 309 -DLE_FUZZ_PLUGIN=heif -DLE_FUZZ_ID=HEIF 310 fuzz_heif_LDADD = $(XLIB) -lm 311 nodist_fuzz_heif_SOURCES = \ 312 $(PLUGIN_DIR)/heif_extractor.c \ 313 $(PLUGIN_DIR)/forensics.c 314 315 fuzz_webp_SOURCES = fuzz_plugin.c 316 fuzz_webp_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 317 -DLE_FUZZ_PLUGIN=webp -DLE_FUZZ_ID=WEBP 318 fuzz_webp_LDADD = $(XLIB) -lm 319 nodist_fuzz_webp_SOURCES = \ 320 $(PLUGIN_DIR)/webp_extractor.c \ 321 $(PLUGIN_DIR)/forensics.c 322 323 fuzz_plist_SOURCES = fuzz_plugin.c 324 fuzz_plist_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 325 -DLE_FUZZ_PLUGIN=plist -DLE_FUZZ_ID=PLIST 326 fuzz_plist_LDADD = $(XLIB) -lm 327 nodist_fuzz_plist_SOURCES = \ 328 $(PLUGIN_DIR)/plist_extractor.c \ 329 $(PLUGIN_DIR)/forensics.c 330 331 fuzz_id3_SOURCES = fuzz_plugin.c 332 fuzz_id3_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 333 -DLE_FUZZ_PLUGIN=id3 -DLE_FUZZ_ID=ID3 334 fuzz_id3_LDADD = $(XLIB) -lm 335 nodist_fuzz_id3_SOURCES = \ 336 $(PLUGIN_DIR)/id3_extractor.c \ 337 $(PLUGIN_DIR)/forensics.c 338 339 fuzz_gpx_SOURCES = fuzz_plugin.c 340 fuzz_gpx_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 341 -DLE_FUZZ_PLUGIN=gpx -DLE_FUZZ_ID=GPX 342 fuzz_gpx_LDADD = $(XLIB) -lm 343 nodist_fuzz_gpx_SOURCES = \ 344 $(PLUGIN_DIR)/gpx_extractor.c \ 345 $(PLUGIN_DIR)/forensics.c 346 347 fuzz_kml_SOURCES = fuzz_plugin.c 348 fuzz_kml_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 349 -DLE_FUZZ_PLUGIN=kml -DLE_FUZZ_ID=KML 350 fuzz_kml_LDADD = $(XLIB) -lm 351 nodist_fuzz_kml_SOURCES = \ 352 $(PLUGIN_DIR)/kml_extractor.c \ 353 $(PLUGIN_DIR)/forensics.c 354 355 fuzz_geotiff_SOURCES = fuzz_plugin.c 356 fuzz_geotiff_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 357 -DLE_FUZZ_PLUGIN=geotiff -DLE_FUZZ_ID=GEOTIFF 358 fuzz_geotiff_LDADD = $(XLIB) -lm 359 nodist_fuzz_geotiff_SOURCES = \ 360 $(PLUGIN_DIR)/geotiff_extractor.c \ 361 $(PLUGIN_DIR)/forensics.c 362 363 fuzz_mbox_SOURCES = fuzz_plugin.c 364 fuzz_mbox_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 365 -DLE_FUZZ_PLUGIN=mbox -DLE_FUZZ_ID=MBOX 366 fuzz_mbox_LDADD = $(XLIB) -lm 367 nodist_fuzz_mbox_SOURCES = \ 368 $(PLUGIN_DIR)/mbox_extractor.c \ 369 $(PLUGIN_DIR)/forensics.c 370 371 372 fuzz_deb_SOURCES = fuzz_plugin.c 373 fuzz_deb_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 374 -DLE_FUZZ_PLUGIN=deb -DLE_FUZZ_ID=DEB 375 fuzz_deb_LDADD = $(XLIB) -lz 376 nodist_fuzz_deb_SOURCES = $(PLUGIN_DIR)/deb_extractor.c 377 378 fuzz_msoffice_SOURCES = fuzz_plugin.c 379 fuzz_msoffice_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 380 -DLE_FUZZ_PLUGIN=msoffice -DLE_FUZZ_ID=MSOFFICE 381 fuzz_msoffice_LDFLAGS = -static 382 fuzz_msoffice_LDADD = $(LE_COMMON) $(XLIB) -lz 383 nodist_fuzz_msoffice_SOURCES = $(PLUGIN_DIR)/msoffice_extractor.c 384 385 fuzz_odf_SOURCES = fuzz_plugin.c 386 fuzz_odf_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 387 -DLE_FUZZ_PLUGIN=odf -DLE_FUZZ_ID=ODF 388 fuzz_odf_LDFLAGS = -static 389 fuzz_odf_LDADD = $(LE_COMMON) $(XLIB) -lz 390 nodist_fuzz_odf_SOURCES = $(PLUGIN_DIR)/odf_extractor.c 391 392 fuzz_png_SOURCES = fuzz_plugin.c 393 fuzz_png_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 394 -DLE_FUZZ_PLUGIN=png -DLE_FUZZ_ID=PNG 395 fuzz_png_LDFLAGS = -static 396 fuzz_png_LDADD = $(LE_COMMON) $(XLIB) -lz 397 nodist_fuzz_png_SOURCES = $(PLUGIN_DIR)/png_extractor.c 398 399 fuzz_qt_SOURCES = fuzz_plugin.c 400 fuzz_qt_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 401 -DLE_FUZZ_PLUGIN=qt -DLE_FUZZ_ID=QT 402 fuzz_qt_LDADD = $(XLIB) -lz 403 nodist_fuzz_qt_SOURCES = $(PLUGIN_DIR)/qt_extractor.c 404 405 fuzz_zip_SOURCES = fuzz_plugin.c 406 fuzz_zip_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 407 -DLE_FUZZ_PLUGIN=zip -DLE_FUZZ_ID=ZIP 408 fuzz_zip_LDFLAGS = -static 409 fuzz_zip_LDADD = $(LE_COMMON) $(XLIB) -lz 410 nodist_fuzz_zip_SOURCES = $(PLUGIN_DIR)/zip_extractor.c 411 412 fuzz_apk_SOURCES = fuzz_plugin.c 413 fuzz_apk_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 414 -DLE_FUZZ_PLUGIN=apk -DLE_FUZZ_ID=APK 415 fuzz_apk_LDFLAGS = -static 416 fuzz_apk_LDADD = $(LE_COMMON) $(XLIB) -lm -lz 417 nodist_fuzz_apk_SOURCES = \ 418 $(PLUGIN_DIR)/apk_extractor.c \ 419 $(PLUGIN_DIR)/forensics.c 420 421 fuzz_ebook_SOURCES = fuzz_plugin.c 422 fuzz_ebook_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 423 -DLE_FUZZ_PLUGIN=ebook -DLE_FUZZ_ID=EBOOK 424 fuzz_ebook_LDFLAGS = -static 425 fuzz_ebook_LDADD = $(LE_COMMON) $(XLIB) -lm -lz 426 nodist_fuzz_ebook_SOURCES = \ 427 $(PLUGIN_DIR)/ebook_extractor.c \ 428 $(PLUGIN_DIR)/forensics.c 429 430 endif 431 432 433 # Plugins that wrap a third-party parser. Their own code is thin, but 434 # the glue -- the part that turns what the library returns into a 435 # metadata callback -- is ours and is worth the same treatment. 436 if HAVE_GIF 437 GIF_FUZZER = fuzz_gif 438 fuzz_gif_SOURCES = fuzz_plugin.c 439 fuzz_gif_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 440 -DLE_FUZZ_PLUGIN=gif -DLE_FUZZ_ID=GIF 441 fuzz_gif_LDADD = $(XLIB) -lgif 442 nodist_fuzz_gif_SOURCES = $(PLUGIN_DIR)/gif_extractor.c 443 endif 444 445 if HAVE_JPEG 446 JPEG_FUZZER = fuzz_jpeg 447 fuzz_jpeg_SOURCES = fuzz_plugin.c 448 fuzz_jpeg_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 449 -DLE_FUZZ_PLUGIN=jpeg -DLE_FUZZ_ID=JPEG 450 fuzz_jpeg_LDADD = $(XLIB) -ljpeg 451 nodist_fuzz_jpeg_SOURCES = $(PLUGIN_DIR)/jpeg_extractor.c 452 endif 453 454 if HAVE_TIFF 455 TIFF_FUZZER = fuzz_tiff 456 fuzz_tiff_SOURCES = fuzz_plugin.c 457 fuzz_tiff_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 458 -DLE_FUZZ_PLUGIN=tiff -DLE_FUZZ_ID=TIFF 459 fuzz_tiff_LDADD = $(XLIB) -ltiff 460 nodist_fuzz_tiff_SOURCES = $(PLUGIN_DIR)/tiff_extractor.c 461 endif 462 463 if HAVE_FLAC 464 FLAC_FUZZER = fuzz_flac 465 fuzz_flac_SOURCES = fuzz_plugin.c 466 fuzz_flac_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 467 -DLE_FUZZ_PLUGIN=flac -DLE_FUZZ_ID=FLAC 468 fuzz_flac_LDADD = $(XLIB) -lFLAC $(LE_LIBINTL) 469 nodist_fuzz_flac_SOURCES = $(PLUGIN_DIR)/flac_extractor.c 470 endif 471 472 if HAVE_VORBISFILE 473 OGG_FUZZER = fuzz_ogg 474 fuzz_ogg_SOURCES = fuzz_plugin.c 475 fuzz_ogg_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 476 -DLE_FUZZ_PLUGIN=ogg -DLE_FUZZ_ID=OGG 477 fuzz_ogg_LDADD = $(XLIB) -lvorbisfile -lvorbis -logg 478 nodist_fuzz_ogg_SOURCES = $(PLUGIN_DIR)/ogg_extractor.c 479 endif 480 481 if HAVE_ARCHIVE 482 ARCHIVE_FUZZER = fuzz_archive 483 fuzz_archive_SOURCES = fuzz_plugin.c 484 fuzz_archive_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 485 -DLE_FUZZ_PLUGIN=archive -DLE_FUZZ_ID=ARCHIVE 486 fuzz_archive_LDADD = $(XLIB) -larchive 487 nodist_fuzz_archive_SOURCES = $(PLUGIN_DIR)/archive_extractor.c 488 endif 489 490 if HAVE_MAGIC 491 MIME_FUZZER = fuzz_mime 492 fuzz_mime_SOURCES = fuzz_plugin.c 493 fuzz_mime_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 494 -DLE_FUZZ_PLUGIN=mime -DLE_FUZZ_ID=MIME 495 fuzz_mime_LDADD = $(XLIB) -lmagic 496 nodist_fuzz_mime_SOURCES = $(PLUGIN_DIR)/mime_extractor.c 497 endif 498 499 # The FFmpeg-based media plugins. What gets instrumented here is our own 500 # glue -- the AVIO callbacks against the fault-injecting extraction 501 # context of fuzz_ec.h, the option parser and the size arithmetic -- and 502 # not FFmpeg's demuxers, which upstream fuzzes far more thoroughly than 503 # we could. Their GStreamer counterparts are deliberately absent: they 504 # dlopen() their decoders and start threads, which does not fit an 505 # in-process deterministic harness (the gstreamer plugin has no target 506 # here either). 507 if HAVE_FFMPEG 508 THUMBNAILFFMPEG_FUZZER = fuzz_thumbnailffmpeg 509 fuzz_thumbnailffmpeg_SOURCES = fuzz_plugin.c 510 fuzz_thumbnailffmpeg_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 511 $(FFMPEG_CFLAGS) \ 512 -DLE_FUZZ_PLUGIN=thumbnailffmpeg -DLE_FUZZ_ID=THUMBNAILFFMPEG 513 fuzz_thumbnailffmpeg_LDADD = $(XLIB) $(FFMPEG_LIBS) -lmagic 514 nodist_fuzz_thumbnailffmpeg_SOURCES = \ 515 $(PLUGIN_DIR)/thumbnailffmpeg_extractor.c \ 516 $(PLUGIN_DIR)/mediaffmpeg.c \ 517 $(PLUGIN_DIR)/mediautil.c 518 endif 519 520 if HAVE_FFMPEG_AUDIO 521 PREVIEWOPUS_FUZZER = fuzz_previewopus 522 fuzz_previewopus_SOURCES = fuzz_plugin.c 523 fuzz_previewopus_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) \ 524 $(FFMPEG_CFLAGS) $(FFMPEG_SWR_CFLAGS) \ 525 -DLE_FUZZ_PLUGIN=previewopus -DLE_FUZZ_ID=PREVIEWOPUS 526 fuzz_previewopus_LDADD = $(XLIB) $(FFMPEG_LIBS) $(FFMPEG_SWR_LIBS) -lmagic 527 nodist_fuzz_previewopus_SOURCES = \ 528 $(PLUGIN_DIR)/previewopus_extractor.c \ 529 $(PLUGIN_DIR)/mediaffmpeg.c \ 530 $(PLUGIN_DIR)/mediautil.c 531 endif 532 533 if HAVE_GSF 534 OLE2_FUZZER = fuzz_ole2 535 fuzz_ole2_SOURCES = fuzz_plugin.c 536 fuzz_ole2_CPPFLAGS = $(AM_CPPFLAGS) -I$(PLUGIN_DIR) $(GSF_CFLAGS) \ 537 -DLE_FUZZ_PLUGIN=ole2 -DLE_FUZZ_ID=OLE2 538 fuzz_ole2_LDFLAGS = -static 539 fuzz_ole2_LDADD = $(LE_COMMON) $(XLIB) $(GSF_LIBS) 540 nodist_fuzz_ole2_SOURCES = $(PLUGIN_DIR)/ole2_extractor.c 541 endif 542 543 544 check_PROGRAMS = \ 545 $(CORE_FUZZERS) \ 546 $(UNZIP_FUZZER) \ 547 $(PLAIN_PLUGIN_FUZZERS) \ 548 $(ZLIB_PLUGIN_FUZZERS) \ 549 $(GIF_FUZZER) \ 550 $(JPEG_FUZZER) \ 551 $(TIFF_FUZZER) \ 552 $(FLAC_FUZZER) \ 553 $(OGG_FUZZER) \ 554 $(ARCHIVE_FUZZER) \ 555 $(MIME_FUZZER) \ 556 $(OLE2_FUZZER) \ 557 $(THUMBNAILFFMPEG_FUZZER) \ 558 $(PREVIEWOPUS_FUZZER) 559 560 TESTS = $(check_PROGRAMS) 561 562 .NOTPARALLEL: 563 564 565 # Regenerate the on-disk seed corpus from the built-in one. 566 .PHONY: refresh-corpus 567 refresh-corpus: $(check_PROGRAMS) 568 for p in $(check_PROGRAMS) ; do \ 569 ./$$p --write-corpus=$(srcdir)/corpus || exit 1 ; \ 570 done 571 $(top_srcdir)/contrib/oss-fuzz/make_seed_corpus.sh \ 572 $(top_srcdir) $(srcdir)/corpus --plain 573 574 # Replay the whole on-disk corpus through every harness; this is what a 575 # CI regression run should do after a crash has been fixed. 576 # 577 # corpus/known-findings/ is listed separately because --corpus-dir does 578 # not recurse. It holds the reproducers of the findings in issues.txt; 579 # anything failing there once its patch has been applied is a regression. 580 CORPUS_DIRS = \ 581 $(srcdir)/corpus \ 582 $(srcdir)/corpus/known-findings 583 584 .PHONY: check-corpus 585 check-corpus: $(check_PROGRAMS) 586 for p in $(check_PROGRAMS) ; do \ 587 for d in $(CORPUS_DIRS) ; do \ 588 test -d $$d || continue ; \ 589 LIBEXTRACTOR_PREFIX="$(abs_top_builddir)/src/plugins/.libs" \ 590 ./$$p --corpus-dir=$$d || exit 1 ; \ 591 done ; \ 592 done