diff --git a/include/share/alloc.h b/include/share/alloc.h index 0b40548e..02bdb300 100644 --- a/include/share/alloc.h +++ b/include/share/alloc.h @@ -194,6 +194,8 @@ static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size static inline void *safe_realloc_(void *ptr, size_t size) { + void *oldptr; + void *newptr; #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION /* Fail if requested */ if(alloc_check() && size > 0) { @@ -201,8 +203,8 @@ static inline void *safe_realloc_(void *ptr, size_t size) return NULL; } #endif - void *oldptr = ptr; - void *newptr = realloc(ptr, size); + oldptr = ptr; + newptr = realloc(ptr, size); if(size > 0 && newptr == 0) free(oldptr); return newptr; diff --git a/oss-fuzz/Makefile.am b/oss-fuzz/Makefile.am index e09d5dc9..2b791bb8 100644 --- a/oss-fuzz/Makefile.am +++ b/oss-fuzz/Makefile.am @@ -17,11 +17,13 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/oss-fuzz -AM_CXXFLAGS = -std=c++11 +AM_CXXFLAGS = -std=c++11 $(LIB_FUZZING_ENGINE) +LDADD = $(flac_libs) + EXTRA_DIST = \ fuzzer_encoder.dict \ - fuzzer_common.h \ + common.h \ Readme.md \ fuzzing/datasource/datasource.hpp \ fuzzing/datasource/id.hpp \ @@ -35,37 +37,12 @@ if USE_OSSFUZZERS noinst_PROGRAMS += fuzzer_encoder fuzzer_encoder_v2 fuzzer_decoder fuzzer_seek fuzzer_metadata fuzzer_reencoder endif -fuzzer_encoder_SOURCES = fuzzer_encoder.cc -fuzzer_encoder_CXXFLAGS = $(AM_CXXFLAGS) $(LIB_FUZZING_ENGINE) -fuzzer_encoder_LDFLAGS = $(AM_LDFLAGS) -fuzzer_encoder_LDADD = $(flac_libs) - -fuzzer_encoder_v2_SOURCES = fuzzer_encoder_v2.cc -fuzzer_encoder_v2_CXXFLAGS = $(AM_CXXFLAGS) $(LIB_FUZZING_ENGINE) -fuzzer_encoder_v2_LDFLAGS = $(AM_LDFLAGS) -fuzzer_encoder_v2_LDADD = $(flac_libs) - -fuzzer_decoder_SOURCES = fuzzer_decoder.cc -fuzzer_decoder_CXXFLAGS = $(AM_CXXFLAGS) $(LIB_FUZZING_ENGINE) -fuzzer_decoder_LDFLAGS = $(AM_LDFLAGS) -fuzzer_decoder_LDADD = $(flac_libs) - -fuzzer_seek_SOURCES = fuzzer_seek.cc -fuzzer_seek_CXXFLAGS = $(AM_CXXFLAGS) $(LIB_FUZZING_ENGINE) -fuzzer_seek_LDFLAGS = $(AM_LDFLAGS) -fuzzer_seek_LDADD = $(flac_libs) - -fuzzer_metadata_SOURCES = fuzzer_metadata.cc -fuzzer_metadata_CXXFLAGS = $(AM_CXXFLAGS) $(LIB_FUZZING_ENGINE) -fuzzer_metadata_LDFLAGS = $(AM_LDFLAGS) -fuzzer_metadata_LDADD = $(flac_libs) - - -fuzzer_reencoder_SOURCES = fuzzer_reencoder.cc -fuzzer_reencoder_CXXFLAGS = $(AM_CXXFLAGS) $(LIB_FUZZING_ENGINE) -fuzzer_reencoder_LDFLAGS = $(AM_LDFLAGS) -fuzzer_reencoder_LDADD = $(flac_libs) - +fuzzer_encoder_SOURCES = encoder.cc +fuzzer_encoder_v2_SOURCES = encoder_v2.cc +fuzzer_decoder_SOURCES = decoder.cc +fuzzer_seek_SOURCES = seek.cc +fuzzer_metadata_SOURCES = metadata.cc +fuzzer_reencoder_SOURCES = reencoder.cc flac_libs = \ $(top_builddir)/src/libFLAC/libFLAC-static.la \ diff --git a/oss-fuzz/fuzzer_common.h b/oss-fuzz/common.h similarity index 100% rename from oss-fuzz/fuzzer_common.h rename to oss-fuzz/common.h diff --git a/oss-fuzz/fuzzer_decoder.cc b/oss-fuzz/decoder.cc similarity index 99% rename from oss-fuzz/fuzzer_decoder.cc rename to oss-fuzz/decoder.cc index b04e2a00..b7ddf218 100644 --- a/oss-fuzz/fuzzer_decoder.cc +++ b/oss-fuzz/decoder.cc @@ -29,7 +29,7 @@ #include "FLAC++/decoder.h" #include "FLAC++/metadata.h" -#include "fuzzer_common.h" +#include "common.h" template <> FLAC__MetadataType fuzzing::datasource::Base::Get(const uint64_t id) { (void)id; diff --git a/oss-fuzz/fuzzer_encoder.cc b/oss-fuzz/encoder.cc similarity index 99% rename from oss-fuzz/fuzzer_encoder.cc rename to oss-fuzz/encoder.cc index be15eb00..23cb3972 100644 --- a/oss-fuzz/fuzzer_encoder.cc +++ b/oss-fuzz/encoder.cc @@ -29,7 +29,7 @@ #include #include "FLAC++/encoder.h" -#include "fuzzer_common.h" +#include "common.h" namespace FLAC { namespace Encoder { diff --git a/oss-fuzz/fuzzer_encoder_v2.cc b/oss-fuzz/encoder_v2.cc similarity index 99% rename from oss-fuzz/fuzzer_encoder_v2.cc rename to oss-fuzz/encoder_v2.cc index 11781a00..3e8d07e1 100644 --- a/oss-fuzz/fuzzer_encoder_v2.cc +++ b/oss-fuzz/encoder_v2.cc @@ -36,7 +36,7 @@ extern "C" { #include "share/private.h" } -#include "fuzzer_common.h" +#include "common.h" /* This C++ fuzzer uses the FLAC and not FLAC++ because the latter lacks a few * hidden functions like FLAC__stream_encoder_disable_constant_subframes. It diff --git a/oss-fuzz/fuzzer_metadata.cc b/oss-fuzz/metadata.cc similarity index 99% rename from oss-fuzz/fuzzer_metadata.cc rename to oss-fuzz/metadata.cc index b667e09d..d03d6dbf 100644 --- a/oss-fuzz/fuzzer_metadata.cc +++ b/oss-fuzz/metadata.cc @@ -34,7 +34,7 @@ #include /* for memcpy */ #include #include "FLAC++/metadata.h" -#include "fuzzer_common.h" +#include "common.h" #define CONFIG_LENGTH 2 diff --git a/oss-fuzz/fuzzer_reencoder.cc b/oss-fuzz/reencoder.cc similarity index 99% rename from oss-fuzz/fuzzer_reencoder.cc rename to oss-fuzz/reencoder.cc index 93bf68fe..457fbd4c 100644 --- a/oss-fuzz/fuzzer_reencoder.cc +++ b/oss-fuzz/reencoder.cc @@ -31,7 +31,7 @@ #include "FLAC++/encoder.h" #include "FLAC++/decoder.h" #include "FLAC++/metadata.h" -#include "fuzzer_common.h" +#include "common.h" #define MAX_NUM_METADATA_BLOCKS 2048 diff --git a/oss-fuzz/fuzzer_seek.cc b/oss-fuzz/seek.cc similarity index 99% rename from oss-fuzz/fuzzer_seek.cc rename to oss-fuzz/seek.cc index a926f68f..33339030 100644 --- a/oss-fuzz/fuzzer_seek.cc +++ b/oss-fuzz/seek.cc @@ -32,7 +32,7 @@ #include #include /* for memcpy */ #include "FLAC/stream_decoder.h" -#include "fuzzer_common.h" +#include "common.h" int write_abort_check_counter = -1;