[poppler] qt5/src qt6/src utils/pdfsig.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 20 11:50:50 UTC 2023


 qt5/src/poppler-form.cc |    4 ++--
 qt6/src/poppler-form.cc |    2 +-
 utils/pdfsig.cc         |    3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

New commits:
commit 2b53d5a8ccb7350c00ef135ab40ca3562099265c
Author: Sune Vuorela <sune at vuorela.dk>
Date:   Mon Mar 20 11:48:42 2023 +0100

    Fixup for 8787103a43
    
    Some codepaths was overlooked; might lead to crashes in pdfsig.
    
    Also clean up the Qt checkpassword functions; they aren't crashers
    though.

diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index b56e73d0..1bead08b 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -781,11 +781,11 @@ bool CertificateInfo::checkPassword(const QString &password) const
 {
 #ifdef ENABLE_NSS3
     Q_D(const CertificateInfo);
-    SignatureHandler sigHandler(d->nick_name.toUtf8().constData(), HashAlgorithm::Sha256);
+    SignatureHandler sigHandler(d->nick_name.toStdString(), HashAlgorithm::Sha256);
     unsigned char buffer[5];
     memcpy(buffer, "test", 5);
     sigHandler.updateHash(buffer, 5);
-    std::unique_ptr<GooString> tmpSignature = sigHandler.signDetached(password.toUtf8().constData());
+    std::unique_ptr<GooString> tmpSignature = sigHandler.signDetached(password.toStdString());
     return tmpSignature.get() != nullptr;
 #else
     return false;
diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc
index 05d183cb..ac138261 100644
--- a/qt6/src/poppler-form.cc
+++ b/qt6/src/poppler-form.cc
@@ -785,7 +785,7 @@ bool CertificateInfo::checkPassword(const QString &password) const
     unsigned char buffer[5];
     memcpy(buffer, "test", 5);
     sigHandler.updateHash(buffer, 5);
-    std::unique_ptr<GooString> tmpSignature = sigHandler.signDetached(password.toUtf8().constData());
+    std::unique_ptr<GooString> tmpSignature = sigHandler.signDetached(password.toStdString());
     return tmpSignature.get() != nullptr;
 #else
     return false;
diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc
index c090f1dc..c494de3c 100644
--- a/utils/pdfsig.cc
+++ b/utils/pdfsig.cc
@@ -439,14 +439,13 @@ int main(int argc, char *argv[])
         if (etsiCAdESdetached) {
             ffs->setSignatureType(ETSI_CAdES_detached);
         }
-        const char *pw = (strlen(password) == 0) ? nullptr : password;
         const auto rs = std::unique_ptr<GooString>(reason.toStr().empty() ? nullptr : utf8ToUtf16WithBom(reason.toStr()));
         if (ffs->getNumWidgets() != 1) {
             printf("Unexpected number of widgets for the signature: %d\n", ffs->getNumWidgets());
             return 2;
         }
         FormWidgetSignature *fws = static_cast<FormWidgetSignature *>(ffs->getWidget(0));
-        const bool success = fws->signDocument(argv[2], certNickname, pw, rs.get());
+        const bool success = fws->signDocument(std::string { argv[2] }, std::string { certNickname }, std::string { password }, rs.get());
         return success ? 0 : 3;
     }
 


More information about the poppler mailing list