diff options
-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) { |