Add pedantic WebP dimensions overflow checking

This commit is contained in:
Přemysl Eric Janouch 2021-12-12 23:39:02 +01:00
parent 6c7d431e35
commit 3ed23e423b
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 6 additions and 1 deletions

View File

@ -1212,8 +1212,13 @@ load_libwebp_animated(const WebPData *wd, GError **error)
WebPAnimDecoder *dec = WebPAnimDecoderNew(wd, &options); WebPAnimDecoder *dec = WebPAnimDecoderNew(wd, &options);
WebPAnimDecoderGetInfo(dec, &info); WebPAnimDecoderGetInfo(dec, &info);
int last_timestamp = 0;
cairo_surface_t *frames = NULL, *frames_tail = NULL; cairo_surface_t *frames = NULL, *frames_tail = NULL;
if (info.canvas_width > INT_MAX || info.canvas_height > INT_MAX) {
set_error(error, "image dimensions overflow");
goto fail;
}
int last_timestamp = 0;
while (WebPAnimDecoderHasMoreFrames(dec)) { while (WebPAnimDecoderHasMoreFrames(dec)) {
cairo_surface_t *surface = cairo_surface_t *surface =
load_libwebp_frame(dec, &info, &last_timestamp, error); load_libwebp_frame(dec, &info, &last_timestamp, error);