File 0002-PSD-enforce-Length-of-image-resource-section-file-si.patch of Package exiv2.9131

From 4eb0b282dfb2ef14213903bdd7c026a8f732233f Mon Sep 17 00:00:00 2001
From: Luis Diaz Mas <piponazo@gmail.com>
Date: Mon, 5 Nov 2018 13:30:18 +0100
Subject: [PATCH 2/2] PSD: enforce Length of image resource section < file size

(cherry picked from commit b7c71f3ad0386cd7af3b73443c0615ada073f0d5)
---
 src/psdimage.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/psdimage.cpp b/src/psdimage.cpp
index 7c5beeff..f7c6ef46 100644
--- a/src/psdimage.cpp
+++ b/src/psdimage.cpp
@@ -38,7 +38,9 @@ EXIV2_RCSID("@(#) $Id$")
 #include "basicio.hpp"
 #include "error.hpp"
 #include "futils.hpp"
+
 #include "safe_op.hpp"
+#include "enforce.hpp"
 
 // + standard includes
 #include <string>
@@ -202,6 +204,8 @@ namespace Exiv2 {
             throw Error(3, "Photoshop");
         }
         uint32_t resourcesLength = getULong(buf, bigEndian);
+        enforce(resourcesLength < io_->size(), Exiv2::kerCorruptedMetadata);
+
         while (resourcesLength > 0)
         {
             if (io_->read(buf, 8) != 8)
-- 
2.25.1

openSUSE Build Service is sponsored by