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

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