From bf151a17a3284460b7c69e0c27ba182f0cb1d00a Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Mon, 5 Sep 2022 23:43:35 +0100 Subject: [PATCH] Don't allow zero width/height in WebPImage::inject_VP8X --- src/webpimage.cpp | 2 ++ test/data/issue_2270_poc.webp | Bin 0 -> 114 bytes tests/bugfixes/github/test_issue_2270.py | 20 ++++++++++++++++++ .../test_regression_allfiles.py | 1 + 4 files changed, 23 insertions(+) create mode 100644 test/data/issue_2270_poc.webp create mode 100644 tests/bugfixes/github/test_issue_2270.py diff --git a/src/webpimage.cpp b/src/webpimage.cpp index ff595c23..861963da 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -752,12 +752,14 @@ void WebPImage::inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_ } /* set width - stored in 24bits*/ + enforce(width > 0, Exiv2::ErrorCode::kerCorruptedMetadata); uint32_t w = width - 1; data[4] = w & 0xFF; data[5] = (w >> 8) & 0xFF; data[6] = (w >> 16) & 0xFF; /* set height - stored in 24bits */ + enforce(width > 0, Exiv2::ErrorCode::kerCorruptedMetadata); uint32_t h = height - 1; data[7] = h & 0xFF; data[8] = (h >> 8) & 0xFF; diff --git a/test/data/issue_2270_poc.webp b/test/data/issue_2270_poc.webp new file mode 100644 index 0000000000000000000000000000000000000000..6e2c4211c920090d680d6f1ebc778ac65ceb7407 GIT binary patch literal 114 zcmWIYbaTsMU|