xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx |   20 
+++++-----
 1 file changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 9d42a2c29d195cdd4cb48acc8a65f5ca7df896c1
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Nov 5 15:03:49 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Nov 6 17:36:47 2022 +0100

    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 <caol...@redhat.com>

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

Reply via email to