diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-11-05 15:03:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-11-06 17:36:47 +0100 |
commit | 9d42a2c29d195cdd4cb48acc8a65f5ca7df896c1 (patch) | |
tree | 4d324bbdbae3cc6023754d9ac9fb24db13249033 /xmlsecurity | |
parent | 35eaff1ad0490b0a1133a594041a6726e5844bd4 (diff) |
sync mscrypt impl with nss impl
Change-Id: I4960f4b8fa1124f98ee2004ffcfc0994916c297e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142335
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index 80ddff58c624..e51b84c40d73 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -41,6 +41,7 @@ #include <biginteger.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/windowserrorstring.hxx> #include <sal/log.hxx> #include <rtl/locale.h> @@ -700,26 +701,25 @@ uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificat return xcert ; } -uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFromAscii( const OUString& asciiCertificate ) { - +uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFromAscii( const OUString& asciiCertificate ) +{ OString oscert = OUStringToOString( asciiCertificate , RTL_TEXTENCODING_ASCII_US ) ; - xmlChar* chCert = xmlStrndup( reinterpret_cast<const xmlChar*>(oscert.getStr()), static_cast<int>(oscert.getLength()) ) ; - xmlSecSize certSize; - xmlSecBase64Decode_ex( chCert, chCert, xmlStrlen( chCert ), &certSize ) ; + int nRet = xmlSecBase64Decode_ex( chCert, reinterpret_cast<xmlSecByte*>(chCert), xmlStrlen( chCert ), &certSize ) ; + if (nRet < 0 || certSize == 0) + { + xmlFree(chCert); + return nullptr; + } - uno::Sequence< sal_Int8 > rawCert( certSize ) ; - auto rawCertRange = asNonConstRange(rawCert); - for( xmlSecSize i = 0 ; i < certSize ; i ++ ) - rawCertRange[i] = *( chCert + i ) ; + uno::Sequence<sal_Int8> rawCert(comphelper::arrayToSequence<sal_Int8>(chCert, certSize)); xmlFree( chCert ) ; return createCertificateFromRaw( rawCert ) ; } - static HCERTSTORE getCertStoreForIntermediatCerts( const uno::Sequence< uno::Reference< css::security::XCertificate > >& seqCerts) { |