[poppler] poppler/Form.cc poppler/SignatureInfo.cc poppler/SignatureInfo.h qt5/src qt6/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 23 13:34:33 UTC 2021


 poppler/Form.cc          |    5 +++--
 poppler/SignatureInfo.cc |   21 +++++++--------------
 poppler/SignatureInfo.h  |   14 ++++++++------
 qt5/src/poppler-form.cc  |    5 +++--
 qt6/src/poppler-form.cc  |    5 +++--
 5 files changed, 24 insertions(+), 26 deletions(-)

New commits:
commit 63c052ec2d4286560075c857261518089c92c315
Author: Georgiy Sgibnev <georgiy at lab50.net>
Date:   Mon Aug 23 11:23:03 2021 +0300

    Correct decoding of signature's properties Reason & Location

diff --git a/poppler/Form.cc b/poppler/Form.cc
index c8194892..57441651 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -30,6 +30,7 @@
 // Copyright 2020 Marek Kasik <mkasik at redhat.com>
 // Copyright 2020 Thorsten Behrens <Thorsten.Behrens at CIB.de>
 // Copyright 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by Technische Universität Dresden
+// Copyright 2021 Georgiy Sgibnev <georgiy at sgibnev.com>. Work sponsored by lab50.net.
 //
 //========================================================================
 
@@ -2075,12 +2076,12 @@ void FormFieldSignature::parseInfo()
 
     const Object location_obj = sig_dict.dictLookup("Location");
     if (location_obj.isString()) {
-        signature_info->setLocation(location_obj.getString()->c_str());
+        signature_info->setLocation(location_obj.getString());
     }
 
     const Object reason_obj = sig_dict.dictLookup("Reason");
     if (reason_obj.isString()) {
-        signature_info->setReason(reason_obj.getString()->c_str());
+        signature_info->setReason(reason_obj.getString());
     }
 
     // retrieve SigningTime
diff --git a/poppler/SignatureInfo.cc b/poppler/SignatureInfo.cc
index 949ba68a..2d2707b4 100644
--- a/poppler/SignatureInfo.cc
+++ b/poppler/SignatureInfo.cc
@@ -10,6 +10,7 @@
 // Copyright 2017-2020 Albert Astals Cid <aacid at kde.org>
 // Copyright 2018 Chinmoy Ranjan Pradhan <chinmoyrp65 at protonmail.com>
 // Copyright 2018 Oliver Sander <oliver.sander at tu-dresden.de>
+// Copyright 2021 Georgiy Sgibnev <georgiy at sgibnev.com>. Work sponsored by lab50.net.
 //
 //========================================================================
 
@@ -36,8 +37,6 @@ SignatureInfo::SignatureInfo()
     cert_info = nullptr;
     signer_name = nullptr;
     subject_dn = nullptr;
-    location = nullptr;
-    reason = nullptr;
     hash_type = HASH_AlgNULL;
     signing_time = 0;
     sig_subfilter_supported = false;
@@ -50,8 +49,6 @@ SignatureInfo::SignatureInfo(SignatureValidationStatus sig_val_status, Certifica
     cert_info = nullptr;
     signer_name = nullptr;
     subject_dn = nullptr;
-    location = nullptr;
-    reason = nullptr;
     hash_type = HASH_AlgNULL;
     signing_time = 0;
     sig_subfilter_supported = false;
@@ -59,8 +56,6 @@ SignatureInfo::SignatureInfo(SignatureValidationStatus sig_val_status, Certifica
 
 SignatureInfo::~SignatureInfo()
 {
-    free(location);
-    free(reason);
     free(signer_name);
     free(subject_dn);
 }
@@ -87,12 +82,12 @@ const char *SignatureInfo::getSubjectDN() const
     return subject_dn;
 }
 
-const char *SignatureInfo::getLocation() const
+const GooString &SignatureInfo::getLocation() const
 {
     return location;
 }
 
-const char *SignatureInfo::getReason() const
+const GooString &SignatureInfo::getReason() const
 {
     return reason;
 }
@@ -136,16 +131,14 @@ void SignatureInfo::setSubjectDN(const char *subjectDN)
     subject_dn = subjectDN ? strdup(subjectDN) : nullptr;
 }
 
-void SignatureInfo::setLocation(const char *loc)
+void SignatureInfo::setLocation(const GooString *loc)
 {
-    free(location);
-    location = strdup(loc);
+    location = GooString(loc->toStr());
 }
 
-void SignatureInfo::setReason(const char *signingReason)
+void SignatureInfo::setReason(const GooString *signingReason)
 {
-    free(reason);
-    reason = strdup(signingReason);
+    reason = GooString(signingReason->toStr());
 }
 
 void SignatureInfo::setHashAlgorithm(int type)
diff --git a/poppler/SignatureInfo.h b/poppler/SignatureInfo.h
index 3ea2a05b..8384cedb 100644
--- a/poppler/SignatureInfo.h
+++ b/poppler/SignatureInfo.h
@@ -10,6 +10,7 @@
 // Copyright 2017 Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
 // Copyright 2018 Chinmoy Ranjan Pradhan <chinmoyrp65 at protonmail.com>
 // Copyright 2018 Oliver Sander <oliver.sander at tu-dresden.de>
+// Copyright 2021 Georgiy Sgibnev <georgiy at sgibnev.com>. Work sponsored by lab50.net.
 //
 //========================================================================
 
@@ -20,6 +21,7 @@
 #include <ctime>
 
 #include "poppler_private_export.h"
+#include "goo/GooString.h"
 
 enum SignatureValidationStatus
 {
@@ -60,8 +62,8 @@ public:
     CertificateValidationStatus getCertificateValStatus() const;
     const char *getSignerName() const;
     const char *getSubjectDN() const;
-    const char *getLocation() const;
-    const char *getReason() const;
+    const GooString &getLocation() const;
+    const GooString &getReason() const;
     int getHashAlgorithm() const; // Returns a NSS3 HASH_HashType or -1 if compiled without NSS3
     time_t getSigningTime() const;
     bool isSubfilterSupported() const { return sig_subfilter_supported; }
@@ -72,8 +74,8 @@ public:
     void setCertificateValStatus(enum CertificateValidationStatus);
     void setSignerName(char *);
     void setSubjectDN(const char *);
-    void setLocation(const char *);
-    void setReason(const char *);
+    void setLocation(const GooString *);
+    void setReason(const GooString *);
     void setHashAlgorithm(int);
     void setSigningTime(time_t);
     void setSubFilterSupport(bool isSupported) { sig_subfilter_supported = isSupported; }
@@ -85,8 +87,8 @@ private:
     std::unique_ptr<X509CertificateInfo> cert_info;
     char *signer_name;
     char *subject_dn;
-    char *location;
-    char *reason;
+    GooString location;
+    GooString reason;
     int hash_type;
     time_t signing_time;
     bool sig_subfilter_supported;
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index b7c8213b..c1456b4c 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -13,6 +13,7 @@
  * Copyright (C) 2020 David García Garzón <voki at canvoki.net>
  * Copyright (C) 2020 Thorsten Behrens <Thorsten.Behrens at CIB.de>
  * Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by Technische Universität Dresden
+ * Copyright (C) 2021 Georgiy Sgibnev <georgiy at sgibnev.com>. Work sponsored by lab50.net.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1037,8 +1038,8 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime &v
     priv->signer_name = si->getSignerName();
     priv->signer_subject_dn = si->getSubjectDN();
     priv->hash_algorithm = si->getHashAlgorithm();
-    priv->location = si->getLocation();
-    priv->reason = si->getReason();
+    priv->location = UnicodeParsedString(si->getLocation().toStr());
+    priv->reason = UnicodeParsedString(si->getReason().toStr());
 
     priv->signing_time = si->getSigningTime();
     const std::vector<Goffset> ranges = fws->getSignedRangeBounds();
diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc
index 0c3f3b8c..b4ebee41 100644
--- a/qt6/src/poppler-form.cc
+++ b/qt6/src/poppler-form.cc
@@ -13,6 +13,7 @@
  * Copyright (C) 2020 David García Garzón <voki at canvoki.net>
  * Copyright (C) 2020 Thorsten Behrens <Thorsten.Behrens at CIB.de>
  * Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by Technische Universität Dresden
+ * Copyright (C) 2021 Georgiy Sgibnev <georgiy at sgibnev.com>. Work sponsored by lab50.net.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1037,8 +1038,8 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime &v
     priv->signer_name = si->getSignerName();
     priv->signer_subject_dn = si->getSubjectDN();
     priv->hash_algorithm = si->getHashAlgorithm();
-    priv->location = si->getLocation();
-    priv->reason = si->getReason();
+    priv->location = UnicodeParsedString(si->getLocation().toStr());
+    priv->reason = UnicodeParsedString(si->getReason().toStr());
 
     priv->signing_time = si->getSigningTime();
     const std::vector<Goffset> ranges = fws->getSignedRangeBounds();


More information about the poppler mailing list