diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-02-26 19:51:39 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-03-03 12:47:50 +0100 |
commit | ca98e505cd69bf95d8ddb9387cf3f8e03ae4577d (patch) | |
tree | b0d899dd2d44a24a446e4f39f4ba1c34a37dfd19 /xmlsecurity | |
parent | 90b725675c2964f4a151d802d9afedd8bc2ae1a7 (diff) |
xmlsecurity: fix crash in DocumentDigitalSignatures::isAuthorTrusted()
If the argument is null.
This function also should use EqualDistinguishedNames().
Change-Id: I4068aa94f9d9c422c96b394c82d3e28303774b0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111667
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/component/documentdigitalsignatures.cxx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index f3b74de8f752..6dfb9799190d 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -655,15 +655,19 @@ void DocumentDigitalSignatures::showCertificate( } sal_Bool DocumentDigitalSignatures::isAuthorTrusted( - const Reference< css::security::XCertificate >& Author ) + const Reference<css::security::XCertificate>& xAuthor) { - OUString sSerialNum = xmlsecurity::bigIntegerToNumericString( Author->getSerialNumber() ); + if (!xAuthor.is()) + { + return false; + } + OUString sSerialNum = xmlsecurity::bigIntegerToNumericString(xAuthor->getSerialNumber()); std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors(); return std::any_of(aTrustedAuthors.begin(), aTrustedAuthors.end(), - [&Author, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { - return ( rAuthor.SubjectName == Author->getIssuerName() ) + [&xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { + return xmlsecurity::EqualDistinguishedNames(rAuthor.SubjectName, xAuthor->getIssuerName()) && ( rAuthor.SerialNumber == sSerialNum ); }); } |