mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
Compare kFuzzPxLimit to max_num_operations
To avoid timeouts caused by extreme rescaling such as 1x14339 -> 51712x1 Change-Id: I291d8e3b24155c190256411a506b7312abde8c45
This commit is contained in:
parent
ed27437160
commit
2d547e24dc
@ -88,10 +88,13 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) {
|
||||
fuzz_px_limit /= 2;
|
||||
}
|
||||
// A big output canvas can lead to out-of-memory and timeout issues,
|
||||
// but a big internal working buffer can too.
|
||||
if ((uint64_t)scaled_width * scaled_height > fuzz_px_limit ||
|
||||
(uint64_t)config.input.width * config.input.height >
|
||||
fuzz_px_limit) {
|
||||
// but a big internal working buffer can too. Also, rescaling from a
|
||||
// very wide input image to a very tall canvas can be as slow as
|
||||
// decoding a huge number of pixels. Avoid timeouts due to these.
|
||||
const uint64_t max_num_operations =
|
||||
(uint64_t)Max(scaled_width, config.input.width) *
|
||||
Max(scaled_height, config.input.height);
|
||||
if (max_num_operations > fuzz_px_limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user