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

4e7124
From 9be257340193dbe3fb810aa33531c40ae9df6414 Mon Sep 17 00:00:00 2001
4e7124
From: Kevin Backhouse <kevinbackhouse@github.com>
4e7124
Date: Wed, 30 Jun 2021 16:47:50 +0100
4e7124
Subject: [PATCH 2/2] Fix incorrect loop condition.
4e7124
4e7124
---
4e7124
 src/jp2image.cpp                                      |  6 ++++--
4e7124
 .../bugfixes/github/test_issue_ghsa_8949_hhfh_j7rj.py | 11 +++++------
4e7124
 2 files changed, 9 insertions(+), 8 deletions(-)
4e7124
4e7124
diff --git a/src/jp2image.cpp b/src/jp2image.cpp
4e7124
index 2cd0a89..58ad5c6 100644
4e7124
--- a/src/jp2image.cpp
4e7124
+++ b/src/jp2image.cpp
4e7124
@@ -619,11 +619,13 @@ namespace Exiv2
4e7124
         char*         p      = (char*) boxBuf.pData_;
4e7124
         bool          bWroteColor = false ;
4e7124
4e7124
-        while ( count < length || !bWroteColor ) {
4e7124
+        while ( count < length && !bWroteColor ) {
4e7124
             Jp2BoxHeader* pSubBox = (Jp2BoxHeader*) (p+count) ;
4e7124
4e7124
             // copy data.  pointer could be into a memory mapped file which we will decode!
4e7124
-            Jp2BoxHeader   subBox = *pSubBox ;
4e7124
+            // pSubBox isn't always an aligned pointer, so use memcpy to do the copy.
4e7124
+            Jp2BoxHeader   subBox;
4e7124
+            memcpy(&subBox, pSubBox, sizeof(Jp2BoxHeader));
4e7124
             Jp2BoxHeader   newBox =  subBox;
4e7124
4e7124
             if ( count < length ) {