OSS-Fuzz: Define ZERO_BUFFERS for MSan build

... and use tj3Alloc() to allocate compression/transformation
destination buffers.
This commit is contained in:
DRC
2024-08-16 12:12:09 -04:00
parent 0c23b0ad60
commit 488d42a8a5
4 changed files with 10 additions and 6 deletions

View File

@@ -9,6 +9,10 @@ if [ $# -ge 1 ]; then
FUZZER_SUFFIX="`echo $1 | sed 's/\./_/g'`"
fi
if [ "$SANITIZER" = "memory" ]; then
export CFLAGS="$CFLAGS -DZERO_BUFFERS=1"
fi
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved.
* Copyright (C)2021, 2023-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved.
* Copyright (C)2021, 2023-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
goto bailout;
} else
dstBuf = NULL;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2021-2023 D. R. Commander. All Rights Reserved.
* Copyright (C)2021-2024 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -70,7 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
transforms[0].op = TJXOP_NONE;
transforms[0].options = TJXOPT_PROGRESSIVE | TJXOPT_COPYNONE;
dstBufs[0] =
(unsigned char *)malloc(tj3JPEGBufSize(width, height, jpegSubsamp));
(unsigned char *)tj3Alloc(tj3JPEGBufSize(width, height, jpegSubsamp));
if (!dstBufs[0])
goto bailout;