aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Even Rouault <even.rouault@spatialys.com>2019-08-12 18:34:37 +0200
committerGravatar jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>2019-08-12 09:34:37 -0700
commit5edcd421d9c170ea30ac9ef82df8f574b6a16dae (patch)
tree6f7ff3f785b143230f8122022dbc167bbbeb6fe0
parent8776ec2327d71470783666f523ab302c57848d1b (diff)
libjpeg-turbo: enable i386 architecture and improve fuzzer regarding msan (#2680)
-rw-r--r--projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc20
-rw-r--r--projects/libjpeg-turbo/project.yaml3
2 files changed, 22 insertions, 1 deletions
diff --git a/projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc b/projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc
index 838e5368..1b9ffd62 100644
--- a/projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc
+++ b/projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc
@@ -39,10 +39,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;
}
- std::unique_ptr<unsigned char[]> buf(new unsigned char[width * height * 3]);
+ const int buffer_size = width * height * 3;
+ std::unique_ptr<unsigned char[]> buf(new unsigned char[buffer_size]);
tjDecompress2(
jpegDecompressor, data, size, buf.get(), width, 0, height, TJPF_RGB, 0);
+ // For memory sanitizer, test each output byte
+ const unsigned char* raw_buf = buf.get();
+ int count = 0;
+ for( int i = 0; i < buffer_size; i++ )
+ {
+ if (raw_buf[i])
+ {
+ count ++;
+ }
+ }
+ if (count == buffer_size)
+ {
+ // Do something with side effect, so that all the above tests don't
+ // get removed by the optimizer.
+ free(malloc(1));
+ }
+
tjDestroy(jpegDecompressor);
return 0;
diff --git a/projects/libjpeg-turbo/project.yaml b/projects/libjpeg-turbo/project.yaml
index f7e4ae56..5ce3c80d 100644
--- a/projects/libjpeg-turbo/project.yaml
+++ b/projects/libjpeg-turbo/project.yaml
@@ -3,3 +3,6 @@ sanitizers:
- address
- memory
- undefined
+architectures:
+ - x86_64
+ - i386