Blame SOURCES/exiv2-CVE-2021-31292.patch

2af963
From 9b7a19f957af53304655ed1efe32253a1b11a8d0 Mon Sep 17 00:00:00 2001
2af963
From: Kevin Backhouse <kevinbackhouse@github.com>
2af963
Date: Fri, 9 Apr 2021 13:37:48 +0100
2af963
Subject: [PATCH] Fix integer overflow.
2af963
2af963
---
2af963
 src/crwimage.cpp | 6 +++++-
2af963
 1 file changed, 5 insertions(+), 1 deletion(-)
2af963
2af963
diff --git a/src/crwimage.cpp b/src/crwimage.cpp
2af963
index ca79aa7..cd6200c 100644
2af963
--- a/src/crwimage.cpp
2af963
+++ b/src/crwimage.cpp
2af963
@@ -1326,7 +1326,11 @@ namespace Exiv2 {
2af963
                                                  pCrwMapping->crwDir_);
2af963
         if (edX != edEnd || edY != edEnd || edO != edEnd) {
2af963
             uint32_t size = 28;
2af963
-            if (cc && cc->size() > size) size = cc->size();
2af963
+            if (cc) {
2af963
+              if (cc->size() < size)
2af963
+                throw Error(kerCorruptedMetadata);
2af963
+              size = cc->size();
2af963
+            }
2af963
             DataBuf buf(size);
2af963
             std::memset(buf.pData_, 0x0, buf.size_);
2af963
             if (cc) std::memcpy(buf.pData_ + 8, cc->pData() + 8, cc->size() - 8);