Blame SOURCES/exiv2-CVE-2018-14046.patch

4a042c
diff --git a/src/webpimage.cpp b/src/webpimage.cpp
4a042c
index e4057d6..f1dd77c 100644
4a042c
--- a/src/webpimage.cpp
4a042c
+++ b/src/webpimage.cpp
4a042c
@@ -44,6 +44,8 @@
4a042c
 #include "tiffimage.hpp"
4a042c
 #include "tiffimage_int.hpp"
4a042c
 #include "convert.hpp"
4a042c
+#include "enforce.hpp"
4a042c
+
4a042c
 #include <cmath>
4a042c
 #include <iomanip>
4a042c
 #include <string>
4a042c
@@ -516,6 +518,8 @@ namespace Exiv2 {
4a042c
             DataBuf payload(size);
4a042c
4a042c
             if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_VP8X) && !has_canvas_data) {
4a042c
+                enforce(size >= 10, Exiv2::kerCorruptedMetadata);
4a042c
+
4a042c
                 has_canvas_data = true;
4a042c
                 byte size_buf[WEBP_TAG_SIZE];
4a042c
4a042c
@@ -531,6 +535,8 @@ namespace Exiv2 {
4a042c
                 size_buf[3] = 0;
4a042c
                 pixelHeight_ = Exiv2::getULong(size_buf, littleEndian) + 1;
4a042c
             } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_VP8) && !has_canvas_data) {
4a042c
+                enforce(size >= 10, Exiv2::kerCorruptedMetadata);
4a042c
+
4a042c
                 has_canvas_data = true;
4a042c
                 io_->read(payload.pData_, payload.size_);
4a042c
                 byte size_buf[WEBP_TAG_SIZE];
4a042c
@@ -547,6 +553,8 @@ namespace Exiv2 {
4a042c
                 size_buf[3] = 0;
4a042c
                 pixelHeight_ = Exiv2::getULong(size_buf, littleEndian) & 0x3fff;
4a042c
             } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_VP8L) && !has_canvas_data) {
4a042c
+                enforce(size >= 5, Exiv2::kerCorruptedMetadata);
4a042c
+
4a042c
                 has_canvas_data = true;
4a042c
                 byte size_buf_w[2];
4a042c
                 byte size_buf_h[3];
4a042c
@@ -564,6 +572,8 @@ namespace Exiv2 {
4a042c
                 size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2);
4a042c
                 pixelHeight_ = Exiv2::getUShort(size_buf_h, littleEndian) + 1;
4a042c
             } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ANMF) && !has_canvas_data) {
4a042c
+                enforce(size >= 12, Exiv2::kerCorruptedMetadata);
4a042c
+
4a042c
                 has_canvas_data = true;
4a042c
                 byte size_buf[WEBP_TAG_SIZE];
4a042c