Skip to content

Commit

Permalink
Merge pull request #11588 from rouault/libertiff_fuzzer
Browse files Browse the repository at this point in the history
fuzzers: add a fuzzer for LIBERTIFF driver
  • Loading branch information
rouault authored Jan 7, 2025
2 parents 17d995e + 890c469 commit 75925d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions fuzzers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ build_gdal_specialized_fuzzer(gdal_sdts GDALRegister_SDTS "/vsimem/test.tar" "/v
build_gdal_specialized_fuzzer(gdal_vrt GDALAllRegister "/vsimem/test.tar" "/vsitar//vsimem/test.tar/test.vrt")
build_gdal_specialized_fuzzer(ers GDALRegister_ERS "/vsimem/test.tar" "/vsitar//vsimem/test.tar/test.ers")

build_fuzzer(
NAME
libertiff_fuzzer
SOURCES
gdal_fuzzer.cpp
DEFINITIONS
-DREGISTER_FUNC=GDALRegister_LIBERTIFF
-DDRIVER_NAME="LIBERTIFF"
)

build_fuzzer(
NAME
gdal_filesystem_fuzzer
Expand Down
2 changes: 2 additions & 0 deletions fuzzers/build_google_oss_fuzzers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ build_gdal_specialized_fuzzer()

build_fuzzer gtiff_mmap $(dirname $0)/gdal_fuzzer.cpp -DREGISTER_FUNC=GDALRegister_GTiff -DGTIFF_USE_MMAP

build_fuzzer libertiff $(dirname $0)/gdal_fuzzer.cpp -DREGISTER_FUNC=GDALRegister_LIBERTIFF -DDRIVER_NAME="\"LIBERTIFF\""

fuzzerFiles="$(dirname $0)/*.cpp"
for F in $fuzzerFiles; do
if test $F != "$(dirname $0)/fuzzingengine.cpp"; then
Expand Down
10 changes: 9 additions & 1 deletion fuzzers/gdal_fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
#else
const char *pszGDALFilename = GDAL_FILENAME;
#endif
GDALDatasetH hDS = GDALOpen(pszGDALFilename, GA_ReadOnly);

#ifdef DRIVER_NAME
const char *const apszAllowedDrivers[] = {DRIVER_NAME, nullptr};
#else
const char *const *apszAllowedDrivers = nullptr;
#endif

GDALDatasetH hDS = GDALOpenEx(pszGDALFilename, GDAL_OF_RASTER,
apszAllowedDrivers, nullptr, nullptr);
if (hDS)
{
const int nTotalBands = GDALGetRasterCount(hDS);
Expand Down

0 comments on commit 75925d1

Please sign in to comment.