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

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 9 17:00:33 UTC 2021


 poppler/Form.cc             |   12 ++++++++++++
 poppler/Form.h              |    2 ++
 qt5/src/poppler-document.cc |    2 +-
 qt6/src/poppler-document.cc |    2 +-
 4 files changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 59d5036451cc55f57e15e4ae1538024c62452978
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Mar 9 17:53:00 2021 +0100

    qt: Fix crash in files with malformed signatures
    
    For signatures we need the formwidget, so even if they don't have the
    Subtype Widget create one when asked for signatures in the document
    
    Fixes KDE bug #433909

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 9937eefd..4d42aedf 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -1975,6 +1975,18 @@ void FormFieldSignature::setCertificateInfo(std::unique_ptr<X509CertificateInfo>
     certificate_info.swap(certInfo);
 }
 
+FormWidget *FormFieldSignature::getCreateWidget()
+{
+    ::FormWidget *fw = getWidget(0);
+    if (!fw) {
+        error(errSyntaxError, 0, "FormFieldSignature: was asked for widget and didn't had one, creating it");
+        _createWidget(&obj, ref);
+        fw = getWidget(0);
+        fw->createWidgetAnnotation();
+    }
+    return fw;
+}
+
 void FormFieldSignature::parseInfo()
 {
     if (!obj.isDict())
diff --git a/poppler/Form.h b/poppler/Form.h
index dcf89760..247fc141 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -617,6 +617,8 @@ public:
 
     void setCertificateInfo(std::unique_ptr<X509CertificateInfo> &);
 
+    FormWidget *getCreateWidget();
+
 private:
     void parseInfo();
     void hashSignedDataBlock(SignatureHandler *handler, Goffset block_len);
diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc
index 0a2a6ce4..c7d38be2 100644
--- a/qt5/src/poppler-document.cc
+++ b/qt5/src/poppler-document.cc
@@ -825,7 +825,7 @@ QVector<FormFieldSignature *> Document::signatures() const
     const std::vector<::FormFieldSignature *> pSignatures = m_doc->doc->getSignatureFields();
 
     for (::FormFieldSignature *pSignature : pSignatures) {
-        ::FormWidget *fw = pSignature->getWidget(0);
+        ::FormWidget *fw = pSignature->getCreateWidget();
         ::Page *p = m_doc->doc->getPage(fw->getWidgetAnnotation()->getPageNum());
         result.append(new FormFieldSignature(m_doc, p, static_cast<FormWidgetSignature *>(fw)));
     }
diff --git a/qt6/src/poppler-document.cc b/qt6/src/poppler-document.cc
index 1a13d46d..150cca0a 100644
--- a/qt6/src/poppler-document.cc
+++ b/qt6/src/poppler-document.cc
@@ -807,7 +807,7 @@ QVector<FormFieldSignature *> Document::signatures() const
     const std::vector<::FormFieldSignature *> pSignatures = m_doc->doc->getSignatureFields();
 
     for (::FormFieldSignature *pSignature : pSignatures) {
-        ::FormWidget *fw = pSignature->getWidget(0);
+        ::FormWidget *fw = pSignature->getCreateWidget();
         ::Page *p = m_doc->doc->getPage(fw->getWidgetAnnotation()->getPageNum());
         result.append(new FormFieldSignature(m_doc, p, static_cast<FormWidgetSignature *>(fw)));
     }


More information about the poppler mailing list