Skip to content

Commit

Permalink
Limit scaling in libwebp advanced_api_fuzzer.c
Browse files Browse the repository at this point in the history
Change-Id: Ic1e3fdc76f4bdcb1ac68cf4f9334d2e77ca29374
  • Loading branch information
y-guyon committed Jan 27, 2023
1 parent b54d21a commit 7361842
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/fuzzer/advanced_api_fuzzer.c
Expand Up @@ -69,9 +69,14 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) {
// files prepended with sizeof(config.options) zeroes to allow the fuzzer
// to modify these independently.
const int data_offset = 50;
if (size > data_offset + sizeof(config.options)) {
memcpy(&config.options, data + data_offset, sizeof(config.options));
} else {
if (data_offset + sizeof(config.options) >= size) break;
memcpy(&config.options, data + data_offset, sizeof(config.options));

// Skip easily avoidable out-of-memory fuzzing errors.
if (config.options.use_scaling && config.options.scaled_width > 0 &&
config.options.scaled_height > 0 &&
(size_t)config.options.scaled_width * config.options.scaled_height >
kFuzzPxLimit) {
break;
}
}
Expand Down

0 comments on commit 7361842

Please sign in to comment.