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