-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Initial work on a libjpeg-turbo fuzzer. #75
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8dcf85d
Initial work on a libjpeg-turbo fuzzer.
alex 38ced39
free memory always
alex cb4e848
oh, this always is supposed to return 0
alex 3594865
larger max_len
alex 0cdea4d
added it to the index
alex 5723d56
use the AFL jpeg corpus
alex 40c2fd0
small fixes
alex 05909c5
Don't try to allocate a 0-byte buffer
alex ba3f182
remove options file, max_len is auto-inferred if you have a corpus
alex e636f52
Merge branch 'master' into libjpeg-turbo
alex 02f15af
Revert changes to this file
alex a767ad8
Copyright header
alex d7f18c3
Bail out on huge inputs
alex d8ce066
use a unique_ptr and new, this is C++!
alex 1a81ac1
forgotten headers
alex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2016 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
FROM ossfuzz/base-libfuzzer | ||
MAINTAINER alex.gaynor@gmail.com | ||
RUN apt-get install -y make autoconf automake libtool nasm curl | ||
RUN git clone https://github.com/libjpeg-turbo/libjpeg-turbo | ||
|
||
RUN mkdir afl-testcases | ||
RUN curl -o afl-testcases/afl_testcases.tgz http://lcamtuf.coredump.cx/afl/demo/afl_testcases.tgz | ||
RUN cd afl-testcases/ && tar -xf afl_testcases.tgz | ||
RUN zip libjpeg_turbo_fuzzer_seed_corpus.zip afl-testcases/jpeg/full/images/* | ||
|
||
COPY build.sh libjpeg_turbo_fuzzer.cc /src/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2016 Google Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
def libfuzzerBuild = fileLoader.fromGit('infra/libfuzzer-pipeline.groovy', | ||
'https://github.com/google/oss-fuzz.git') | ||
|
||
libfuzzerBuild { | ||
git = "https://github.com/libjpeg-turbo/libjpeg-turbo" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash -eu | ||
# Copyright 2016 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
cd /src/libjpeg-turbo | ||
|
||
autoreconf -fiv | ||
./configure | ||
make "-j$(nproc)" | ||
|
||
$CXX $CXXFLAGS -std=c++11 -I. \ | ||
/src/libjpeg_turbo_fuzzer.cc -o /out/libjpeg_turbo_fuzzer \ | ||
-lfuzzer ./.libs/libturbojpeg.a $FUZZER_LDFLAGS | ||
|
||
cp /src/libjpeg_turbo_fuzzer_seed_corpus.zip /out/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
# Copyright 2016 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#include <memory> | ||
|
||
#include <turbojpeg.h> | ||
|
||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
tjhandle jpegDecompressor = tjInitDecompress(); | ||
|
||
int width, height, subsamp, colorspace; | ||
int res = tjDecompressHeader3( | ||
jpegDecompressor, data, size, &width, &height, &subsamp, &colorspace); | ||
|
||
// Bail out if decompressing the headers failed, the width or height is 0, | ||
// or the image is too large (avoids slowing down too much) | ||
if (res != 0 || width == 0 || height == 0 || (width * height > (1024 * 1024))) { | ||
tjDestroy(jpegDecompressor); | ||
return 0; | ||
} | ||
|
||
std::unique_ptr<unsigned char[]> buf(new unsigned char[width * height * 3]); | ||
tjDecompress2( | ||
jpegDecompressor, data, size, buf.get(), width, 0, height, TJPF_RGB, 0); | ||
|
||
tjDestroy(jpegDecompressor); | ||
|
||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This need copyright headers.