aboutsummaryrefslogtreecommitdiffstats
path: root/fuzz
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-10-22 12:27:25 +0200
committerJay Berkenbilt <ejb@ql.org>2020-10-22 12:31:52 +0200
commit232f5fc9f3bed8e1b02bca5d10b2eca444e30f95 (patch)
treea28fd45c3425ef3445b53d58482e9d442ef63d5b /fuzz
parentc1684eae9144129027642f5069a0fd97f0559ec8 (diff)
downloadqpdf-232f5fc9f3bed8e1b02bca5d10b2eca444e30f95.tar.zst
Handle jpeg library fuzz false positives
The jpeg library has some assembly code that is missed by the compiler instrumentation used by memory sanitization. There is a runtime environment variable that is used to work around this issue.
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/dct_fuzzer.cc6
-rw-r--r--fuzz/qpdf_fuzzer.cc6
2 files changed, 12 insertions, 0 deletions
diff --git a/fuzz/dct_fuzzer.cc b/fuzz/dct_fuzzer.cc
index 450b4df2..b051819a 100644
--- a/fuzz/dct_fuzzer.cc
+++ b/fuzz/dct_fuzzer.cc
@@ -2,6 +2,7 @@
#include <qpdf/Pl_DCT.hh>
#include <iostream>
#include <stdexcept>
+#include <cstdlib>
class FuzzHelper
{
@@ -46,6 +47,11 @@ FuzzHelper::run()
extern "C" int LLVMFuzzerTestOneInput(unsigned char const* data, size_t size)
{
+#ifndef _WIN32
+ // Used by jpeg library to work around false positives in memory
+ // sanitizer.
+ setenv("JSIMD_FORCENONE", "1", 1);
+#endif
FuzzHelper f(data, size);
f.run();
return 0;
diff --git a/fuzz/qpdf_fuzzer.cc b/fuzz/qpdf_fuzzer.cc
index 32b9a0fb..eb6791a4 100644
--- a/fuzz/qpdf_fuzzer.cc
+++ b/fuzz/qpdf_fuzzer.cc
@@ -9,6 +9,7 @@
#include <qpdf/QPDFPageLabelDocumentHelper.hh>
#include <qpdf/QPDFOutlineDocumentHelper.hh>
#include <qpdf/QPDFAcroFormDocumentHelper.hh>
+#include <cstdlib>
class DiscardContents: public QPDFObjectHandle::ParserCallbacks
{
@@ -223,6 +224,11 @@ FuzzHelper::run()
extern "C" int LLVMFuzzerTestOneInput(unsigned char const* data, size_t size)
{
+#ifndef _WIN32
+ // Used by jpeg library to work around false positives in memory
+ // sanitizer.
+ setenv("JSIMD_FORCENONE", "1", 1);
+#endif
FuzzHelper f(data, size);
f.run();
return 0;