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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:40:33 UTC 2017


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

The following commit has been merged in the master branch:
commit fbc3b58f143e75643002523d1fd0027bd76da9f8
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sun Jun 14 14:33:56 2009 +0000

    #638: Fixed compiler warnings, fixed more CRC issues, shortened some code.
---
 src/pngchunk.cpp     | 316 +++++++++++++++++++--------------------------------
 src/pngchunk_int.hpp |  44 ++++---
 2 files changed, 134 insertions(+), 226 deletions(-)

diff --git a/src/pngchunk.cpp b/src/pngchunk.cpp
index 7509f39..32f137a 100644
--- a/src/pngchunk.cpp
+++ b/src/pngchunk.cpp
@@ -52,11 +52,13 @@ extern "C" {
 #include "error.hpp"
 
 // + standard includes
+#include <sstream>
+#include <iomanip>
 #include <string>
 #include <cstring>
 #include <iostream>
 #include <cassert>
-#include <cstdarg>
+#include <cstdio>
 
 /*
 
@@ -359,27 +361,39 @@ namespace Exiv2 {
 
     DataBuf PngChunk::makeMetadataChunk(const DataBuf& metadata, MetadataType type, bool compress)
     {
-        DataBuf buf;
-        DataBuf rawProfile;
+        // Todo: Return std::string instead of DataBuf, take metadata also as a std::string
+
+        std::string chunk;
 
         switch (type) {
         case comment_Data:
-            buf = makeUtf8TxtChunk("Description", metadata, compress);
+        {
+            std::string text((const char*)metadata.pData_, metadata.size_);
+            chunk = makeUtf8TxtChunk("Description", text, compress);
             break;
+        }
         case exif_Data:
-            rawProfile = writeRawProfile(metadata, "exif");
-            buf = makeAsciiTxtChunk("Raw profile type exif", rawProfile, compress);
+        {
+            std::string rawProfile = writeRawProfile(metadata, "exif");
+            chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, compress);
             break;
+        }
         case iptc_Data:
-            rawProfile = writeRawProfile(metadata, "iptc");
-            buf = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, compress);
+        {
+            std::string rawProfile = writeRawProfile(metadata, "iptc");
+            chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, compress);
             break;
+        }
         case xmp_Data:
-            buf = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, compress);
+            std::string text((const char*)metadata.pData_, metadata.size_);
+            chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", text, compress);
             break;
         }
 
+        DataBuf buf(chunk.size());
+        chunk.copy((char*)buf.pData_, buf.size_);
         return buf;
+
     } // PngChunk::makeMetadataChunk
 
     void PngChunk::zlibUncompress(const byte*  compressedText,
@@ -425,169 +439,115 @@ namespace Exiv2 {
 
     } // PngChunk::zlibUncompress
 
-    void PngChunk::zlibCompress(const byte*  text,
-                                unsigned int textSize,
-                                DataBuf&     arr)
+    std::string PngChunk::zlibCompress(const std::string& text)
     {
-        uLongf compressedLen = textSize * 2; // just a starting point
+        uLongf compressedLen = text.size() * 2; // just a starting point
         int zlibResult;
 
-        do
-        {
+        DataBuf arr;
+        do {
             arr.alloc(compressedLen);
             zlibResult = compress2((Bytef*)arr.pData_, &compressedLen,
-                                   text, textSize, Z_BEST_COMPRESSION);
+                                   (const Bytef*)text.data(), text.size(),
+                                   Z_BEST_COMPRESSION);
 
-            if (zlibResult == Z_OK)
-            {
-                // then it is all OK
-                arr.alloc(compressedLen);
+            switch (zlibResult) {
+            case Z_OK:
+                assert((uLongf)arr.size_ >= compressedLen);
                 arr.size_ = compressedLen;
-            }
-            else if (zlibResult == Z_BUF_ERROR)
-            {
-                // the compressedArray needs to be larger
+                break;
+            case Z_BUF_ERROR:
+                // The compressed array needs to be larger
 #ifdef DEBUG
                 std::cout << "Exiv2::PngChunk::parsePngChunk: doubling size for compression.
";
 #endif
                 compressedLen *= 2;
-
-                // DoS protection. can't be bigger than 64k
-                if ( compressedLen > 131072 )
-                    break;
-            }
-            else
-            {
-                // something bad happened
+                // DoS protection. Cap max compressed size
+                if ( compressedLen > 131072 ) throw Error(14);
+                break;
+            default:
+                // Something bad happened
                 throw Error(14);
             }
-        }
-        while (zlibResult == Z_BUF_ERROR);
+        } while (zlibResult == Z_BUF_ERROR);
 
-        if (zlibResult != Z_OK)
-            throw Error(14);
+        return std::string((const char*)arr.pData_, arr.size_);
 
     } // PngChunk::zlibCompress
 
-    DataBuf PngChunk::makeAsciiTxtChunk(const char* key, const DataBuf& data, bool compress)
+    std::string PngChunk::makeAsciiTxtChunk(const std::string& keyword,
+                                            const std::string& text,
+                                            bool               compress)
     {
-        DataBuf type(4);
-        DataBuf data4crc;
-        DataBuf chunkData;
-        byte    chunkDataSize[4];
-        byte    chunkCRC[4];
-        long    keylen = strlen(key);
-
-        if (compress)
-        {
-            // Compressed text chunk using ZLib.
-            // Data format    : key ("zTXt") + 0x00 + compression type (0x00) + compressed data
-            // Chunk structure: data length (4 bytes) + chunk type (4 bytes) + compressed data + CRC (4 bytes)
-
-            memcpy(type.pData_, "zTXt", 4);
-
-            DataBuf compressedData;
-            zlibCompress(data.pData_, data.size_, compressedData);
-
-            data4crc.alloc(keylen + 1 + 1 + compressedData.size_);
-            memcpy(data4crc.pData_, key, keylen);
-            memcpy(data4crc.pData_ + keylen, "

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list