[poppler] glib/poppler-form-field.cc poppler/SignatureInfo.cc poppler/SignatureInfo.h qt5/src qt6/src utils/pdfsig.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Mar 8 13:56:35 UTC 2023
glib/poppler-form-field.cc | 2 +-
poppler/SignatureInfo.cc | 28 +++++++++-------------------
poppler/SignatureInfo.h | 12 ++++++------
qt5/src/poppler-form.cc | 4 ++--
qt6/src/poppler-form.cc | 4 ++--
utils/pdfsig.cc | 4 ++--
6 files changed, 22 insertions(+), 32 deletions(-)
New commits:
commit c335934c1c30ab3ec1dd963f4646ae88d5790172
Author: Sune Vuorela <sune at vuorela.dk>
Date: Tue Mar 7 15:30:55 2023 +0100
Use std::string for strings
not manual strdup/free
diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc
index 314b2cfc..c1f0fc39 100644
--- a/glib/poppler-form-field.cc
+++ b/glib/poppler-form-field.cc
@@ -468,7 +468,7 @@ static PopplerSignatureInfo *_poppler_form_field_signature_validate(PopplerFormF
break;
}
- poppler_sig_info->signer_name = g_strdup(sig_info->getSignerName());
+ poppler_sig_info->signer_name = g_strdup(sig_info->getSignerName().c_str());
poppler_sig_info->local_signing_time = g_date_time_new_from_unix_local(sig_info->getSigningTime());
return poppler_sig_info;
diff --git a/poppler/SignatureInfo.cc b/poppler/SignatureInfo.cc
index fc8fe323..de26ec20 100644
--- a/poppler/SignatureInfo.cc
+++ b/poppler/SignatureInfo.cc
@@ -32,8 +32,6 @@ SignatureInfo::SignatureInfo()
sig_status = SIGNATURE_NOT_VERIFIED;
cert_status = CERTIFICATE_NOT_VERIFIED;
cert_info = nullptr;
- signer_name = nullptr;
- subject_dn = nullptr;
hash_type = HashAlgorithm::Unknown;
signing_time = 0;
sig_subfilter_supported = false;
@@ -44,18 +42,12 @@ SignatureInfo::SignatureInfo(SignatureValidationStatus sig_val_status, Certifica
sig_status = sig_val_status;
cert_status = cert_val_status;
cert_info = nullptr;
- signer_name = nullptr;
- subject_dn = nullptr;
hash_type = HashAlgorithm::Unknown;
signing_time = 0;
sig_subfilter_supported = false;
}
-SignatureInfo::~SignatureInfo()
-{
- free(signer_name);
- free(subject_dn);
-}
+SignatureInfo::~SignatureInfo() { }
/* GETTERS */
@@ -69,12 +61,12 @@ CertificateValidationStatus SignatureInfo::getCertificateValStatus() const
return cert_status;
}
-const char *SignatureInfo::getSignerName() const
+std::string SignatureInfo::getSignerName() const
{
return signer_name;
}
-const char *SignatureInfo::getSubjectDN() const
+std::string SignatureInfo::getSubjectDN() const
{
return subject_dn;
}
@@ -116,26 +108,24 @@ void SignatureInfo::setCertificateValStatus(enum CertificateValidationStatus cer
cert_status = cert_val_status;
}
-void SignatureInfo::setSignerName(const char *signerName)
+void SignatureInfo::setSignerName(const std::string &signerName)
{
- free(signer_name);
- signer_name = signerName ? strdup(signerName) : nullptr;
+ signer_name = signerName;
}
-void SignatureInfo::setSubjectDN(const char *subjectDN)
+void SignatureInfo::setSubjectDN(const std::string &subjectDN)
{
- free(subject_dn);
- subject_dn = subjectDN ? strdup(subjectDN) : nullptr;
+ subject_dn = subjectDN;
}
void SignatureInfo::setLocation(const GooString *loc)
{
- location = GooString(loc->toStr());
+ location = GooString(loc);
}
void SignatureInfo::setReason(const GooString *signingReason)
{
- reason = GooString(signingReason->toStr());
+ reason = GooString(signingReason);
}
void SignatureInfo::setHashAlgorithm(HashAlgorithm type)
diff --git a/poppler/SignatureInfo.h b/poppler/SignatureInfo.h
index 85311db4..1a75990f 100644
--- a/poppler/SignatureInfo.h
+++ b/poppler/SignatureInfo.h
@@ -64,8 +64,8 @@ public:
/* GETTERS */
SignatureValidationStatus getSignatureValStatus() const;
CertificateValidationStatus getCertificateValStatus() const;
- const char *getSignerName() const;
- const char *getSubjectDN() const;
+ std::string getSignerName() const;
+ std::string getSubjectDN() const;
const GooString &getLocation() const;
const GooString &getReason() const;
HashAlgorithm getHashAlgorithm() const; // Returns the used HashAlgorithm, and unknown if compiled without signature support
@@ -76,8 +76,8 @@ public:
/* SETTERS */
void setSignatureValStatus(enum SignatureValidationStatus);
void setCertificateValStatus(enum CertificateValidationStatus);
- void setSignerName(const char *);
- void setSubjectDN(const char *);
+ void setSignerName(const std::string &);
+ void setSubjectDN(const std::string &);
void setLocation(const GooString *);
void setReason(const GooString *);
void setHashAlgorithm(HashAlgorithm);
@@ -89,8 +89,8 @@ private:
SignatureValidationStatus sig_status;
CertificateValidationStatus cert_status;
std::unique_ptr<X509CertificateInfo> cert_info;
- char *signer_name;
- char *subject_dn;
+ std::string signer_name;
+ std::string subject_dn;
GooString location;
GooString reason;
HashAlgorithm hash_type;
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 235b79ae..011eb3ea 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -1072,8 +1072,8 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime &v
priv->certificate_status = SignatureValidationInfo::CertificateNotVerified;
break;
}
- priv->signer_name = si->getSignerName();
- priv->signer_subject_dn = si->getSubjectDN();
+ priv->signer_name = QString::fromStdString(si->getSignerName());
+ priv->signer_subject_dn = QString::fromStdString(si->getSubjectDN());
priv->hash_algorithm = si->getHashAlgorithm();
priv->location = UnicodeParsedString(si->getLocation().toStr());
priv->reason = UnicodeParsedString(si->getReason().toStr());
diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc
index 876e0588..86671971 100644
--- a/qt6/src/poppler-form.cc
+++ b/qt6/src/poppler-form.cc
@@ -1072,8 +1072,8 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime &v
priv->certificate_status = SignatureValidationInfo::CertificateNotVerified;
break;
}
- priv->signer_name = si->getSignerName();
- priv->signer_subject_dn = si->getSubjectDN();
+ priv->signer_name = QString::fromStdString(si->getSignerName());
+ priv->signer_subject_dn = QString::fromStdString(si->getSubjectDN());
priv->hash_algorithm = si->getHashAlgorithm();
priv->location = UnicodeParsedString(si->getLocation().toStr());
priv->reason = UnicodeParsedString(si->getReason().toStr());
diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc
index 9722c6a1..ee6d9881 100644
--- a/utils/pdfsig.cc
+++ b/utils/pdfsig.cc
@@ -490,8 +490,8 @@ int main(int argc, char *argv[])
}
const SignatureInfo *sig_info = ffs->validateSignature(!dontVerifyCert, false, -1 /* now */, !noOCSPRevocationCheck, useAIACertFetch);
- printf(" - Signer Certificate Common Name: %s\n", sig_info->getSignerName());
- printf(" - Signer full Distinguished Name: %s\n", sig_info->getSubjectDN());
+ printf(" - Signer Certificate Common Name: %s\n", sig_info->getSignerName().c_str());
+ printf(" - Signer full Distinguished Name: %s\n", sig_info->getSubjectDN().c_str());
printf(" - Signing Time: %s\n", time_str = getReadableTime(sig_info->getSigningTime()));
printf(" - Signing Hash Algorithm: ");
switch (sig_info->getHashAlgorithm()) {
More information about the poppler
mailing list