-
-
Notifications
You must be signed in to change notification settings - Fork 708
Add buffer with args fuzzer #4103
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
6 commits
Select commit
Hold shift + click to select a range
c8b4287
add generic buffer with args fuzzer
dloebl 0c80427
Simplify
kleisauke 1228b78
fuzz seed corpus: add webpsave leak
dloebl 57b1b67
add more test cases to the seed corpus
dloebl 0fa1fef
add vips_init call
dloebl 9a1a56a
Merge branch 'master' into add-generic-args-fuzzer
dloebl 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
Binary file not shown.
Binary file added
BIN
+817 Bytes
fuzz/common_fuzzer_corpus/generic_buffer_with_args_gif_to_gif_all_pages
Binary file not shown.
Binary file added
BIN
+823 Bytes
fuzz/common_fuzzer_corpus/generic_buffer_with_args_gif_to_webp_all_pages
Binary file not shown.
Binary file added
BIN
+731 Bytes
fuzz/common_fuzzer_corpus/generic_buffer_with_args_gif_to_webp_page_three
Binary file not shown.
Binary file not shown.
Binary file not shown.
39 changes: 39 additions & 0 deletions
39
fuzz/common_fuzzer_corpus/generic_buffer_with_args_pdf_to_png
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,39 @@ | ||
[n=-1,page=0,dpi=72,scale=0.1,password=secret] | ||
.png[filter=none] | ||
%PDF-1.1 | ||
%âãÏÓ | ||
1 0 obj | ||
<< | ||
/Pages 2 0 R | ||
/Type /Catalog | ||
>> | ||
endobj | ||
2 0 obj | ||
<< | ||
/MediaBox [0 0 595 842] | ||
/Kids [3 0 R] | ||
/Count 1 | ||
/Type /Pages | ||
>> | ||
endobj | ||
3 0 obj | ||
<< | ||
/Parent 2 0 R | ||
/MediaBox [0 0 595 842] | ||
/Type /Page | ||
>> | ||
endobj xref | ||
0 4 | ||
0000000000 65535 f | ||
0000000015 00000 n | ||
0000000066 00000 n | ||
0000000149 00000 n | ||
trailer | ||
|
||
<< | ||
/Root 1 0 R | ||
/Size 4 | ||
>> | ||
startxref | ||
221 | ||
%%EOF |
Binary file not shown.
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,81 @@ | ||
#include <vips/vips.h> | ||
|
||
#define MAX_ARG_LEN 4096 // =VIPS_PATH_MAX | ||
|
||
extern "C" int | ||
LLVMFuzzerInitialize(int *argc, char ***argv) | ||
{ | ||
if (VIPS_INIT(*argv[0])) | ||
return -1; | ||
|
||
vips_concurrency_set(1); | ||
return 0; | ||
} | ||
|
||
static char * | ||
ExtractLine(const guint8 *data, size_t size, size_t *n) | ||
{ | ||
const guint8 *end; | ||
|
||
end = static_cast<const guint8 *>( | ||
memchr(data, '\n', VIPS_MIN(size, MAX_ARG_LEN))); | ||
if (end == nullptr) | ||
return nullptr; | ||
|
||
*n = end - data; | ||
return g_strndup(reinterpret_cast<const char *>(data), *n); | ||
} | ||
|
||
extern "C" int | ||
LLVMFuzzerTestOneInput(const guint8 *data, size_t size) | ||
{ | ||
VipsImage *image; | ||
void *buf; | ||
char *option_string, *suffix; | ||
size_t len, n; | ||
|
||
option_string = ExtractLine(data, size, &n); | ||
if (option_string == nullptr) | ||
return 0; | ||
|
||
data += n + 1; | ||
size -= n + 1; | ||
|
||
suffix = ExtractLine(data, size, &n); | ||
if (suffix == nullptr) { | ||
g_free(option_string); | ||
return 0; | ||
} | ||
|
||
data += n + 1; | ||
size -= n + 1; | ||
|
||
if (!(image = vips_image_new_from_buffer(data, size, option_string, nullptr))) { | ||
g_free(option_string); | ||
g_free(suffix); | ||
return 0; | ||
} | ||
|
||
// We're done with option_string, free early. | ||
g_free(option_string); | ||
|
||
if (image->Xsize > 100 || | ||
image->Ysize > 100 || | ||
image->Bands > 4) { | ||
g_object_unref(image); | ||
g_free(suffix); | ||
return 0; | ||
} | ||
|
||
if (vips_image_write_to_buffer(image, suffix, &buf, &len, nullptr)) { | ||
g_object_unref(image); | ||
g_free(suffix); | ||
return 0; | ||
} | ||
|
||
g_free(buf); | ||
g_free(suffix); | ||
g_object_unref(image); | ||
|
||
return 0; | ||
} |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.