OSS-Fuzz: Define ZERO_BUFFERS for MSan build
... and use tj3Alloc() to allocate compression/transformation destination buffers.
This commit is contained in:
@@ -9,6 +9,10 @@ if [ $# -ge 1 ]; then
|
|||||||
FUZZER_SUFFIX="`echo $1 | sed 's/\./_/g'`"
|
FUZZER_SUFFIX="`echo $1 | sed 's/\./_/g'`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$SANITIZER" = "memory" ]; then
|
||||||
|
export CFLAGS="$CFLAGS -DZERO_BUFFERS=1"
|
||||||
|
fi
|
||||||
|
|
||||||
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
|
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
|
||||||
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \
|
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \
|
||||||
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
|
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* 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);
|
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
|
||||||
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
|
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
|
||||||
if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
|
if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
|
||||||
goto bailout;
|
goto bailout;
|
||||||
} else
|
} else
|
||||||
dstBuf = NULL;
|
dstBuf = NULL;
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* 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);
|
maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp);
|
||||||
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
|
if (tj3Get(handle, TJPARAM_NOREALLOC)) {
|
||||||
if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL)
|
if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL)
|
||||||
goto bailout;
|
goto bailout;
|
||||||
} else
|
} else
|
||||||
dstBuf = NULL;
|
dstBuf = NULL;
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* 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].op = TJXOP_NONE;
|
||||||
transforms[0].options = TJXOPT_PROGRESSIVE | TJXOPT_COPYNONE;
|
transforms[0].options = TJXOPT_PROGRESSIVE | TJXOPT_COPYNONE;
|
||||||
dstBufs[0] =
|
dstBufs[0] =
|
||||||
(unsigned char *)malloc(tj3JPEGBufSize(width, height, jpegSubsamp));
|
(unsigned char *)tj3Alloc(tj3JPEGBufSize(width, height, jpegSubsamp));
|
||||||
if (!dstBufs[0])
|
if (!dstBufs[0])
|
||||||
goto bailout;
|
goto bailout;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user