File CVE-2019-14368.patch of Package exiv2-0_26.26888

From bd0afe0390439b2c424d881c8c6eb0c5624e31d9 Mon Sep 17 00:00:00 2001
From: Kevin Backhouse <kev@semmle.com>
Date: Mon, 15 Jul 2019 13:30:38 +0100
Subject: [PATCH] Add bounds check to MemIo::seek(). (#944)

- Add bounds check to MemIo::seek(), this fixes CVE-2019-13504
---
 src/basicio.cpp            |  7 +++-

Index: exiv2-0.26/src/basicio.cpp
===================================================================
--- exiv2-0.26.orig/src/basicio.cpp
+++ exiv2-0.26/src/basicio.cpp
@@ -1208,7 +1208,12 @@ namespace Exiv2 {
         case BasicIo::end: newIdx = p_->size_ + offset; break;
         }
 
-        p_->idx_ = static_cast<long>(newIdx);   //not very sure about this. need more test!!    - note by Shawn  fly2xj@gmail.com //TODO
+        if (static_cast<size_t>(newIdx) > p_->size_) {
+            p_->eof_ = true;
+            return 1;
+        }
+
+        p_->idx_ = static_cast<size_t>(newIdx);
         p_->eof_ = false;
         return 0;
     }
openSUSE Build Service is sponsored by