diff options
author | Yannis Guyon <yguyon@google.com> | 2023-02-08 10:53:40 +0100 |
---|---|---|
committer | Yannis Guyon <yguyon@google.com> | 2023-02-08 10:53:40 +0100 |
commit | 1347a32d82276ecf4daba12f6e9142cc4e1f2401 (patch) | |
tree | 23ea485277d8284f8e22d374a815baa258042c82 | |
parent | 52b6f0670381917161e3d7089f5b0ab5f13acbf1 (diff) | |
download | libwebp-1347a32d82276ecf4daba12f6e9142cc4e1f2401.tar.gz |
Skip big scaled advanced_api_fuzzer
To avoid timeouts.
Change-Id: I8f04fd45313bef47004a616d2460be992692030d
-rw-r--r-- | tests/fuzzer/advanced_api_fuzzer.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/fuzzer/advanced_api_fuzzer.c b/tests/fuzzer/advanced_api_fuzzer.c index 291d0c03..1378d0bc 100644 --- a/tests/fuzzer/advanced_api_fuzzer.c +++ b/tests/fuzzer/advanced_api_fuzzer.c @@ -22,7 +22,6 @@ #include "src/webp/decode.h" int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { - int i; WebPDecoderConfig config; if (!WebPInitDecoderConfig(&config)) return 0; if (WebPGetFeatures(data, size, &config.input) != VP8_STATUS_OK) return 0; @@ -64,7 +63,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { config.output.colorspace = (WEBP_CSP_MODE)(value % MODE_LAST); #endif // WEBP_REDUCE_CSP - for (i = 0; i < 2; ++i) { + for (int i = 0; i < 2; ++i) { if (i == 1) { // Use the bitstream data to generate extreme ranges for the options. An // alternative approach would be to use a custom corpus containing webp @@ -80,9 +79,21 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { int scaled_height = config.options.scaled_height; if (WebPRescalerGetScaledDimensions(config.input.width, config.input.height, &scaled_width, - &scaled_height) && - (uint64_t)scaled_width * scaled_height > kFuzzPxLimit) { - break; + &scaled_height)) { + size_t fuzz_px_limit = kFuzzPxLimit; + if (scaled_width != config.input.width || + scaled_height != config.input.height) { + // Using the WebPRescalerImport internally can significantly slow + // down the execution. Avoid timeouts due to that. + 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) { + break; + } } } } |