Properly validate picture dimensions for overflow

Change-Id: I42735f6c651d0bb768b9c727209a7b5fe991b456
This commit is contained in:
Vincent Rabaud
2025-11-19 23:08:08 +01:00
parent df24b5632e
commit 4ebf0b0ac8

View File

@@ -50,11 +50,8 @@ int WebPPictureInitInternal(WebPPicture* picture, int version) {
int WebPValidatePicture(const WebPPicture* const picture) {
if (picture == NULL) return 0;
if (picture->width <= 0 || picture->height <= 0) {
return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION);
}
if (picture->width <= 0 || picture->width / 4 > INT_MAX / 4 ||
picture->height <= 0 || picture->height / 4 > INT_MAX / 4) {
if (picture->width <= 0 || picture->width > INT_MAX / 4 ||
picture->height <= 0 || picture->height > INT_MAX / 4) {
return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION);
}
if (picture->colorspace != WEBP_YUV420 &&