[poppler] poppler/Form.cc poppler/SignatureHandler.cc poppler/SignatureHandler.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 7 11:46:15 UTC 2021
poppler/Form.cc | 6 +-----
poppler/SignatureHandler.cc | 10 +++++-----
poppler/SignatureHandler.h | 2 +-
3 files changed, 7 insertions(+), 11 deletions(-)
New commits:
commit ef18170e6ec6e117df4d24497b16dd8cc8b42ca3
Author: Marek Kasik <mkasik at redhat.com>
Date: Tue Dec 7 11:46:13 2021 +0000
SignatureHandler: Return std::string in getSignerName()
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 921a89e6..cb6f62f8 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -2191,14 +2191,10 @@ SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool for
hashSignedDataBlock(&signature_handler, len);
}
- char *signerName = signature_handler.getSignerName();
-
- signature_info->setSignerName(signerName);
+ signature_info->setSignerName(signature_handler.getSignerName().c_str());
signature_info->setSubjectDN(signature_handler.getSignerSubjectDN());
signature_info->setHashAlgorithm(signature_handler.getHashAlgorithm());
- free(signerName);
-
if (!signature_info->isSubfilterSupported()) {
error(errUnimplemented, 0, "Unable to validate this type of signature");
return signature_info;
diff --git a/poppler/SignatureHandler.cc b/poppler/SignatureHandler.cc
index f5d4c284..41e89970 100644
--- a/poppler/SignatureHandler.cc
+++ b/poppler/SignatureHandler.cc
@@ -501,21 +501,21 @@ SECOidTag SignatureHandler::getHashOidTag(const char *digestName)
return tag;
}
-char *SignatureHandler::getSignerName()
+std::string SignatureHandler::getSignerName()
{
- char *commonName, *name;
+ char *commonName;
if (!CMSSignerInfo || !NSS_IsInitialized())
- return nullptr;
+ return {};
if (!signing_cert)
signing_cert = NSS_CMSSignerInfo_GetSigningCertificate(CMSSignerInfo, CERT_GetDefaultCertDB());
if (!signing_cert)
- return nullptr;
+ return {};
commonName = CERT_GetCommonName(&signing_cert->subject);
- name = strdup(commonName);
+ std::string name(commonName);
PORT_Free(commonName);
return name;
diff --git a/poppler/SignatureHandler.h b/poppler/SignatureHandler.h
index b4a8b60b..db416b79 100644
--- a/poppler/SignatureHandler.h
+++ b/poppler/SignatureHandler.h
@@ -48,7 +48,7 @@ public:
SignatureHandler(const char *certNickname, SECOidTag digestAlgTag);
~SignatureHandler();
time_t getSigningTime();
- char *getSignerName();
+ std::string getSignerName();
const char *getSignerSubjectDN();
HASH_HashType getHashAlgorithm();
void setSignature(unsigned char *, int);
More information about the poppler
mailing list