Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libjpeg-turbo: enable i386 architecture and improve fuzzer regarding msan #2680

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed bad that MSAN doesn't complain about this automatically (google/sanitizers#883)
That being said, you want __msan_check_mem_is_initialized().

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;
Expand Down
3 changes: 3 additions & 0 deletions projects/libjpeg-turbo/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ sanitizers:
- address
- memory
- undefined
architectures:
- x86_64
- i386