[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:36:44 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=2ed876f

The following commit has been merged in the master branch:
commit 2ed876f6157ed5c6781af509862ead0e3d2a51bf
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sat Nov 13 07:58:36 2004 +0000

    Fixed ExifKey (and IptcKey) behaviour for unknown tag (record) names
---
 src/datasets.cpp |  2 +-
 src/tags.cpp     |  8 +++++---
 src/types.cpp    | 14 ++++++++++++++
 src/types.hpp    |  9 +++++++++
 4 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/datasets.cpp b/src/datasets.cpp
index c661cda..81c2c1c 100644
--- a/src/datasets.cpp
+++ b/src/datasets.cpp
@@ -271,7 +271,7 @@ namespace Exiv2 {
             if (recordInfo_[i].name_ == recordName) break;
         }
         if (i == 0) {
-            // Todo: Check format of recordName
+            if (!isHex(recordName, 4, "0x")) throw Error("Invalid record name");
             std::istringstream is(recordName);
             is >> std::hex >> i;
         }
diff --git a/src/tags.cpp b/src/tags.cpp
index d120263..8cd874b 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -326,7 +326,7 @@ namespace Exiv2 {
             tag = tagInfo[idx].tag_;
         }
         if (tag == 0xffff) {
-            // Todo: Check format of tagName
+            if (!isHex(tagName, 4, "0x")) throw Error("Invalid tag name");
             std::istringstream is(tagName);
             is >> std::hex >> tag;
         }
@@ -371,9 +371,11 @@ namespace Exiv2 {
                                      IfdId ifdId,
                                      const Value& value)
     {
+        PrintFct fct = printValue;
         int idx = tagInfoIdx(tag, ifdId);
-        if (idx == -1) throw Error("No taginfo for IFD");
-        PrintFct fct = tagInfos_[ifdId][idx].printFct_;
+        if (idx != -1) {
+            fct = tagInfos_[ifdId][idx].printFct_;
+        }
         return fct(os, value);
     }
 
diff --git a/src/types.cpp b/src/types.cpp
index c469cf4..551d6e1 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -39,6 +39,7 @@ EXIV2_RCSID("@(#) $Id$");
 #include <iomanip>
 #include <sstream>
 #include <utility>
+#include <cctype>
 
 // *****************************************************************************
 // class member definitions
@@ -282,4 +283,17 @@ namespace Exiv2 {
         return b;
     } // lgcd
 
+    bool isHex(const std::string& str, size_t size, const std::string& prefix)
+    {
+        if (   str.size() <= prefix.size() 
+            || str.substr(0, prefix.size()) != prefix) return false;
+        if (   size > 0
+            && str.size() != size + prefix.size()) return false;
+        
+        for (size_t i = prefix.size(); i < str.size(); ++i) {
+            if (!isxdigit(str[i])) return false;
+        }
+        return true;
+    } // isHex
+
 }                                       // namespace Exiv2
diff --git a/src/types.hpp b/src/types.hpp
index d2b00ff..f6221d8 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -270,6 +270,15 @@ namespace Exiv2 {
              Both parameters must be greater than 0.
      */
     long lgcd(long a, long b);
+
+    /*!
+      @brief Return true if str is a hex number starting with prefix followed
+             by size hex digits, false otherwise. If size is 0, any number of 
+             digits is allowed and all are checked.
+     */
+    bool isHex(const std::string& str, 
+               size_t size =0,
+               const std::string& prefix ="");
    
 // *****************************************************************************
 // template and inline definitions

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list