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

001fe5
From 13e5a3e02339b746abcaee6408893ca2fd8e289d Mon Sep 17 00:00:00 2001
001fe5
From: Pydera <pydera@mailbox.org>
001fe5
Date: Thu, 8 Apr 2021 17:36:16 +0200
001fe5
Subject: [PATCH] Fix out of buffer access in #1529
001fe5
001fe5
---
001fe5
 src/jp2image.cpp | 5 +++--
001fe5
 1 file changed, 3 insertions(+), 2 deletions(-)
001fe5
001fe5
diff --git a/src/jp2image.cpp b/src/jp2image.cpp
001fe5
index 4c072d7..ba025a3 100644
001fe5
--- a/src/jp2image.cpp
001fe5
+++ b/src/jp2image.cpp
001fe5
@@ -739,9 +739,10 @@ namespace Exiv2
001fe5
 #endif
001fe5
                 box.length = io_->size() - io_->tell() + 8;
001fe5
             }
001fe5
-            if (box.length == 1)
001fe5
+            if (box.length < 8)
001fe5
             {
001fe5
-                // FIXME. Special case. the real box size is given in another place.
001fe5
+                // box is broken, so there is nothing we can do here
001fe5
+                throw Error(14);
001fe5
             }
001fe5
001fe5
             // Read whole box : Box header + Box data (not fixed size - can be null).