Fix fuzzer when one scaled dimension is 0

BUG: 470038406

Change-Id: If64f841bde21ca80822d6c4e0f228b7d00f326d7
This commit is contained in:
Vincent Rabaud
2025-12-19 09:10:35 +00:00
parent a9f3b447ae
commit d078f7d201
2 changed files with 14 additions and 7 deletions

View File

@@ -51,7 +51,7 @@ link_fuzztest(fuzz_utils)
add_webp_fuzztest(advanced_api_fuzzer webpdecode webpdspdecode webputilsdecode)
add_webp_fuzztest(dec_fuzzer)
add_webp_fuzztest(enc_dec_fuzzer)
add_webp_fuzztest(enc_dec_fuzzer webpdecode webpdspdecode webputilsdecode)
add_webp_fuzztest(enc_fuzzer imagedec)
add_webp_fuzztest(huffman_fuzzer webpdecode webpdspdecode webputilsdecode)
add_webp_fuzztest(imageio_fuzzer imagedec)

View File

@@ -23,6 +23,7 @@
#include "./fuzz_utils.h"
#include "src/dsp/cpu.h"
#include "src/utils/rescaler_utils.h"
#include "src/webp/decode.h"
#include "src/webp/encode.h"
@@ -191,12 +192,18 @@ void EncDecTest(bool use_argb, fuzz_utils::WebPPictureCpp pic_cpp,
fprintf(stderr, "WebPInitDecoderConfig failed.\n");
abort();
}
if (decoder_options.use_scaling &&
static_cast<size_t>(decoder_options.scaled_width) *
decoder_options.scaled_height >
1000u * 1000u) {
// Skip huge scaling.
return;
if (decoder_options.use_scaling) {
int scaled_width = decoder_options.scaled_width;
int scaled_height = decoder_options.scaled_height;
if (!WebPRescalerGetScaledDimensions(pic.width, pic.height, &scaled_width,
&scaled_height)) {
// Rescaled dimensions do not make sense.
return;
}
if (static_cast<uint64_t>(scaled_width) * scaled_height > 1000u * 1000u) {
// Skip huge scaling.
return;
}
}
dec_config.output.colorspace = static_cast<WEBP_CSP_MODE>(colorspace);