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