summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-29 10:29:41 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-11-01 09:55:03 +0100
commitd12f25905c3d7e474b603a716669b12143b6c34a (patch)
treee6050b21f43f09bf5105b0a073ef8dc3ae3fbe55 /xmlsecurity
parentf16f35d40948bd4bbe835e0ba3c2f75aa0de23f7 (diff)
Prepare for removal of non-const operator[] from Sequence in xmlsecurity
Change-Id: I7cfcf9f9ea307bd737292e6f4f37a29f453167c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124418 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/framework/saxeventkeeperimpl.cxx15
-rw-r--r--xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx12
-rw-r--r--xmlsecurity/source/gpg/SecurityEnvironment.cxx3
-rw-r--r--xmlsecurity/source/helper/pdfsignaturehelper.cxx3
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx5
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx12
-rw-r--r--xmlsecurity/source/helper/xsecverify.cxx5
-rw-r--r--xmlsecurity/source/xmlsec/biginteger.cxx8
-rw-r--r--xmlsecurity/source/xmlsec/certificateextension_certextn.cxx15
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx12
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx9
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx21
-rw-r--r--xmlsecurity/source/xmlsec/nss/ciphercontext.cxx5
-rw-r--r--xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx6
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx18
-rw-r--r--xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx47
-rw-r--r--xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx5
17 files changed, 78 insertions, 123 deletions
diff --git a/xmlsecurity/source/framework/saxeventkeeperimpl.cxx b/xmlsecurity/source/framework/saxeventkeeperimpl.cxx
index b1d960241702..b5a7f027287f 100644
--- a/xmlsecurity/source/framework/saxeventkeeperimpl.cxx
+++ b/xmlsecurity/source/framework/saxeventkeeperimpl.cxx
@@ -30,6 +30,8 @@
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
+#include <algorithm>
+
SAXEventKeeperImpl::SAXEventKeeperImpl( )
:m_pCurrentBufferNode(nullptr),
m_nNextElementMarkId(1),
@@ -345,12 +347,8 @@ css::uno::Sequence< css::uno::Reference< css::xml::wrapper::XXMLElementWrapper >
css::uno::Sequence < css::uno::Reference<
css::xml::wrapper::XXMLElementWrapper > > aChildrenCollection ( vChildren.size());
- sal_Int32 nIndex = 0;
- for( const auto& i : vChildren )
- {
- aChildrenCollection[nIndex] = i->getXMLElement();
- nIndex++;
- }
+ std::transform(vChildren.begin(), vChildren.end(), aChildrenCollection.getArray(),
+ [](const auto& i) { return i->getXMLElement(); });
return aChildrenCollection;
}
@@ -998,11 +996,12 @@ void SAL_CALL SAXEventKeeperImpl::startElement(
{
sal_Int32 nLength = xAttribs->getLength();
css::uno::Sequence< css::xml::csax::XMLAttribute > aAttributes (nLength);
+ auto aAttributesRange = asNonConstRange(aAttributes);
for ( int i = 0; i<nLength; ++i )
{
- aAttributes[i].sName = xAttribs->getNameByIndex(static_cast<short>(i));
- aAttributes[i].sValue =xAttribs->getValueByIndex(static_cast<short>(i));
+ aAttributesRange[i].sName = xAttribs->getNameByIndex(static_cast<short>(i));
+ aAttributesRange[i].sValue =xAttribs->getValueByIndex(static_cast<short>(i));
}
m_xCompressedDocumentHandler->compressedStartElement(aName, aAttributes);
diff --git a/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx b/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx
index de6cf54cd206..203f0fea2072 100644
--- a/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx
+++ b/xmlsecurity/source/framework/xmlsignaturetemplateimpl.cxx
@@ -56,17 +56,7 @@ void SAL_CALL XMLSignatureTemplateImpl::setTarget( const css::uno::Reference< cs
css::uno::Sequence< css::uno::Reference< css::xml::wrapper::XXMLElementWrapper > > SAL_CALL XMLSignatureTemplateImpl::getTargets()
{
- sal_Int32 length = targets.size();
- css::uno::Sequence< css::uno::Reference< css::xml::wrapper::XXMLElementWrapper > > aTargets (length);
-
- sal_Int32 i;
-
- for (i=0; i<length; i++)
- {
- aTargets[i] = targets[i];
- }
-
- return aTargets;
+ return comphelper::containerToSequence(targets);
}
void SAL_CALL XMLSignatureTemplateImpl::setBinding(
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
index b864700ec30d..da2310765315 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -138,9 +138,10 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getCertificatesIm
}
Sequence< Reference< XCertificate > > xCertificateSequence(certsList.size());
+ auto xCertificateSequenceRange = asNonConstRange(xCertificateSequence);
int i = 0;
for (const auto& cert : certsList) {
- xCertificateSequence[i++] = cert;
+ xCertificateSequenceRange[i++] = cert;
}
return xCertificateSequence;
diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
index 95fca26f5945..5aa2088ea7fd 100644
--- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
@@ -498,11 +498,12 @@ PDFSignatureHelper::GetDocumentSignatureInformations(
const uno::Reference<xml::crypto::XSecurityEnvironment>& xSecEnv) const
{
uno::Sequence<security::DocumentSignatureInformation> aRet(m_aSignatureInfos.size());
+ auto aRetRange = asNonConstRange(aRet);
for (size_t i = 0; i < m_aSignatureInfos.size(); ++i)
{
const SignatureInformation& rInternal = m_aSignatureInfos[i];
- security::DocumentSignatureInformation& rExternal = aRet[i];
+ security::DocumentSignatureInformation& rExternal = aRetRange[i];
rExternal.SignatureIsValid
= rInternal.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
if (rInternal.GetSigningCertificate()
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 334864775851..6436f9f7c627 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -508,9 +508,10 @@ void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<c
SAL_WARN("xmlsecurity.helper", "no defaults or overrides in aContentTypeInfo");
return;
}
+ auto pContentTypeInfo = aContentTypeInfo.getArray();
// Append rels and sigs to defaults, if it's not there already.
- uno::Sequence<beans::StringPair>& rDefaults = aContentTypeInfo[0];
+ uno::Sequence<beans::StringPair>& rDefaults = pContentTypeInfo[0];
auto aDefaults = comphelper::sequenceToContainer< std::vector<beans::StringPair> >(rDefaults);
if (std::none_of(std::cbegin(rDefaults), std::cend(rDefaults), [](const beans::StringPair& rPair) { return rPair.First == "rels"; }))
aDefaults.emplace_back("rels", "application/vnd.openxmlformats-package.relationships+xml");
@@ -520,7 +521,7 @@ void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<c
rDefaults = comphelper::containerToSequence(aDefaults);
// Remove existing signature overrides.
- uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1];
+ uno::Sequence<beans::StringPair>& rOverrides = pContentTypeInfo[1];
auto aOverrides = comphelper::sequenceToContainer< std::vector<beans::StringPair> >(rOverrides);
aOverrides.erase(std::remove_if(aOverrides.begin(), aOverrides.end(), [](const beans::StringPair& rPair)
{
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index e793be4337f2..e1caea0fade9 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -202,8 +202,8 @@ void XSecController::createXSecComponent( )
*/
return;
- css::uno::Sequence <css::uno::Any> arg(1);
- arg[0] <<= uno::Reference<xml::wrapper::XXMLDocumentWrapper>(m_xXMLDocumentWrapper);
+ css::uno::Sequence <css::uno::Any> arg{ css::uno::Any(
+ uno::Reference<xml::wrapper::XXMLDocumentWrapper>(m_xXMLDocumentWrapper)) };
m_xSAXEventKeeper->initialize(arg);
css::uno::Reference< css::xml::crypto::sax::XSAXEventKeeperStatusChangeListener >
@@ -280,9 +280,7 @@ bool XSecController::chainOn()
css::uno::Reference< css::lang::XInitialization > xInitialization
(m_xPreviousNodeOnSAXChain, css::uno::UNO_QUERY);
- css::uno::Sequence<css::uno::Any> aArgs( 1 );
- aArgs[0] <<= xSEKHandler;
- xInitialization->initialize(aArgs);
+ xInitialization->initialize({ css::uno::Any(xSEKHandler) });
}
else
{
@@ -328,8 +326,8 @@ void XSecController::chainOff()
css::uno::Reference< css::lang::XInitialization > xInitialization
(m_xPreviousNodeOnSAXChain, css::uno::UNO_QUERY);
- css::uno::Sequence<css::uno::Any> aArgs( 1 );
- aArgs[0] <<= uno::Reference<xml::sax::XDocumentHandler>();
+ css::uno::Sequence<css::uno::Any> aArgs{ css::uno::Any(
+ uno::Reference<xml::sax::XDocumentHandler>()) };
xInitialization->initialize(aArgs);
}
else
diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx
index 10fc8dc9eb1d..46f087801bd5 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -40,6 +40,7 @@
#include <unotools/datetime.hxx>
#include <comphelper/base64.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/seqstream.hxx>
namespace com::sun::star::graphic { class XGraphic; }
@@ -485,9 +486,7 @@ Reference<css::graphic::XGraphic> lcl_getGraphicFromString(const OUString& rImag
graphic::GraphicProvider::create(comphelper::getProcessComponentContext()) );
Reference< io::XInputStream > xInputStream( new ::comphelper::SequenceInputStream( seq ) );
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[ 0 ].Name = "InputStream";
- aArgs[ 0 ].Value <<= xInputStream;
+ Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("InputStream", xInputStream) };
xGraphic = xGraphicProvider->queryGraphic(aArgs);
return xGraphic;
diff --git a/xmlsecurity/source/xmlsec/biginteger.cxx b/xmlsecurity/source/xmlsec/biginteger.cxx
index 3615eb73a54a..1a4ab6fd9d13 100644
--- a/xmlsecurity/source/xmlsec/biginteger.cxx
+++ b/xmlsecurity/source/xmlsec/biginteger.cxx
@@ -23,6 +23,8 @@
#include <xmlsec-wrapper.h>
#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/sequence.hxx>
+
using namespace ::com::sun::star::uno ;
namespace xmlsecurity
@@ -63,11 +65,7 @@ Sequence< sal_Int8 > numericStringToBigInteger ( std::u16string_view numeral )
return Sequence< sal_Int8 >();
}
- Sequence< sal_Int8 > integer( length ) ;
- for( xmlSecSize i = 0 ; i < length ; i ++ )
- {
- integer[i] = *( bnInteger + i ) ;
- }
+ Sequence< sal_Int8 > integer = comphelper::arrayToSequence<sal_Int8>(bnInteger, length);
xmlSecBnFinalize( &bn ) ;
return integer ;
diff --git a/xmlsecurity/source/xmlsec/certificateextension_certextn.cxx b/xmlsecurity/source/xmlsec/certificateextension_certextn.cxx
index b7b5f1e9df1c..d7325759de21 100644
--- a/xmlsecurity/source/xmlsec/certificateextension_certextn.cxx
+++ b/xmlsecurity/source/xmlsec/certificateextension_certextn.cxx
@@ -19,6 +19,8 @@
#include "certificateextension_certextn.hxx"
+#include <comphelper/sequence.hxx>
+
CertificateExtension_CertExtn::CertificateExtension_CertExtn()
: m_critical(false)
{
@@ -27,23 +29,14 @@ CertificateExtension_CertExtn::CertificateExtension_CertExtn()
void CertificateExtension_CertExtn::setCertExtn(const unsigned char* value, unsigned int vlen,
const unsigned char* id, unsigned int idlen, bool critical)
{
- unsigned int i ;
if( value != nullptr && vlen != 0 ) {
- css::uno::Sequence< sal_Int8 > extnv( vlen ) ;
- for( i = 0; i < vlen ; i ++ )
- extnv[i] = *( value + i ) ;
-
- m_xExtnValue = extnv ;
+ m_xExtnValue = comphelper::arrayToSequence<sal_Int8>(value, vlen);
} else {
m_xExtnValue = css::uno::Sequence<sal_Int8>();
}
if( id != nullptr && idlen != 0 ) {
- css::uno::Sequence< sal_Int8 > extnId( idlen ) ;
- for( i = 0; i < idlen ; i ++ )
- extnId[i] = *( id + i ) ;
-
- m_xExtnId = extnId ;
+ m_xExtnId = comphelper::arrayToSequence<sal_Int8>(id, idlen);
} else {
m_xExtnId = css::uno::Sequence<sal_Int8>();
}
diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx
index 8c58ffada322..6ded5fa0cb9c 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx
@@ -83,10 +83,8 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
css::beans::NamedValue otherNameProp;
otherNameProp.Name = OUString::createFromAscii(pOtherName->pszObjId);
- Sequence< sal_Int8 > otherName( pOtherName->Value.cbData ) ;
- for( unsigned int n = 0; n < static_cast<unsigned int>(pOtherName->Value.cbData) ; n ++ )
- otherName[n] = *( pOtherName->Value.pbData + n ) ;
-
+ Sequence< sal_Int8 > otherName( comphelper::arrayToSequence<sal_Int8>(
+ pOtherName->Value.pbData, pOtherName->Value.cbData) );
otherNameProp.Value <<= otherName;
arrCertAltNameEntry[i].Value <<= otherNameProp;
@@ -113,10 +111,8 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
{
arrCertAltNameEntry[i].Type = ExtAltNameType_IP_ADDRESS;
- Sequence< sal_Int8 > ipAddress( pEntry->IPAddress.cbData ) ;
- for( unsigned int n = 0; n < pEntry->IPAddress.cbData ; n ++ )
- ipAddress[n] = *( pEntry->IPAddress.pbData + n ) ;
-
+ Sequence< sal_Int8 > ipAddress( comphelper::arrayToSequence<sal_Int8>(
+ pEntry->IPAddress.pbData, pEntry->IPAddress.cbData) );
arrCertAltNameEntry[i].Value <<= ipAddress;
break;
}
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index f33306f7cac8..bd1de6cbf85d 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
@@ -361,9 +361,10 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
if( length != 0 ) {
int i = 0;
uno::Sequence< uno::Reference< XCertificate > > certSeq( length ) ;
+ auto pcertSeq = certSeq.getArray();
for( const auto& rXCert : certsList ) {
- certSeq[i] = rXCert ;
+ pcertSeq[i] = rXCert ;
++i;
}
@@ -661,6 +662,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
pCertChain = pChainContext->rgpChain[0] ;
if( pCertChain->cElement ) {
uno::Sequence< uno::Reference< XCertificate > > xCertChain( pCertChain->cElement ) ;
+ auto pxCertChain = xCertChain.getArray();
for( unsigned int i = 0 ; i < pCertChain->cElement ; i ++ ) {
if( pCertChain->rgpElement[i] )
@@ -671,7 +673,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
if( pCertInChain != nullptr ) {
pCert = MswcryCertContextToXCert( pCertInChain ) ;
if( pCert.is() )
- xCertChain[i] = pCert ;
+ pxCertChain[i] = pCert ;
}
}
@@ -707,8 +709,9 @@ uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificat
xmlSecSize certSize = xmlSecBase64Decode( chCert, chCert, xmlStrlen( chCert ) ) ;
uno::Sequence< sal_Int8 > rawCert( certSize ) ;
+ auto rawCertRange = asNonConstRange(rawCert);
for( xmlSecSize i = 0 ; i < certSize ; i ++ )
- rawCert[i] = *( chCert + i ) ;
+ rawCertRange[i] = *( chCert + i ) ;
xmlFree( chCert ) ;
diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx
index e8b86858d337..5e0ca9094b19 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx
@@ -198,8 +198,9 @@ sal_Int16 SAL_CALL X509Certificate_MSCryptImpl::getVersion() {
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSerialNumber() {
if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) {
Sequence< sal_Int8 > serial( m_pCertContext->pCertInfo->SerialNumber.cbData ) ;
+ auto serialRange = asNonConstRange(serial);
for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->SerialNumber.cbData ; i ++ )
- serial[i] = *( m_pCertContext->pCertInfo->SerialNumber.pbData + m_pCertContext->pCertInfo->SerialNumber.cbData - i - 1 ) ;
+ serialRange[i] = *( m_pCertContext->pCertInfo->SerialNumber.pbData + m_pCertContext->pCertInfo->SerialNumber.cbData - i - 1 ) ;
return serial ;
} else {
@@ -338,8 +339,9 @@ css::util::DateTime SAL_CALL X509Certificate_MSCryptImpl::getNotValidAfter() {
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getIssuerUniqueID() {
if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) {
Sequence< sal_Int8 > issuerUid( m_pCertContext->pCertInfo->IssuerUniqueId.cbData ) ;
+ auto issuerUidRange = asNonConstRange(issuerUid);
for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->IssuerUniqueId.cbData; i ++ )
- issuerUid[i] = *( m_pCertContext->pCertInfo->IssuerUniqueId.pbData + i ) ;
+ issuerUidRange[i] = *( m_pCertContext->pCertInfo->IssuerUniqueId.pbData + i ) ;
return issuerUid ;
} else {
@@ -350,8 +352,9 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getIssuerUn
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectUniqueID() {
if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) {
Sequence< sal_Int8 > subjectUid( m_pCertContext->pCertInfo->SubjectUniqueId.cbData ) ;
+ auto subjectUidRange = asNonConstRange(subjectUid);
for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->SubjectUniqueId.cbData; i ++ )
- subjectUid[i] = *( m_pCertContext->pCertInfo->SubjectUniqueId.pbData + i ) ;
+ subjectUidRange[i] = *( m_pCertContext->pCertInfo->SubjectUniqueId.pbData + i ) ;
return subjectUid ;
} else {
@@ -363,6 +366,7 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr && m_pCertContext->pCertInfo->cExtension != 0 ) {
rtl::Reference<CertificateExtension_XmlSecImpl> xExtn ;
Sequence< Reference< XCertificateExtension > > xExtns( m_pCertContext->pCertInfo->cExtension ) ;
+ auto pExtns = xExtns.getArray();
for( unsigned int i = 0; i < m_pCertContext->pCertInfo->cExtension; i++ ) {
CERT_EXTENSION* pExtn = &(m_pCertContext->pCertInfo->rgExtension[i]) ;
@@ -377,7 +381,7 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, reinterpret_cast<unsigned char*>(pExtn->pszObjId), strlen( pExtn->pszObjId ), pExtn->fCritical ) ;
- xExtns[i] = xExtn ;
+ pExtns[i] = xExtn ;
}
return xExtns ;
@@ -410,9 +414,10 @@ css::uno::Reference< css::security::XCertificateExtension > SAL_CALL X509Certifi
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getEncoded() {
if( m_pCertContext != nullptr && m_pCertContext->cbCertEncoded > 0 ) {
Sequence< sal_Int8 > rawCert( m_pCertContext->cbCertEncoded ) ;
+ auto prawCert = rawCert.getArray();
for( unsigned int i = 0 ; i < m_pCertContext->cbCertEncoded ; i ++ )
- rawCert[i] = *( m_pCertContext->pbCertEncoded + i ) ;
+ prawCert[i] = *( m_pCertContext->pbCertEncoded + i ) ;
return rawCert ;
} else {
@@ -478,9 +483,10 @@ static css::uno::Sequence< sal_Int8 > getThumbprint(const CERT_CONTEXT* pCertCon
if (CertGetCertificateContextProperty(pCertContext, dwPropId, fingerprint, &cbData))
{
Sequence< sal_Int8 > thumbprint( cbData ) ;
+ auto pthumbprint = thumbprint.getArray();
for( unsigned int i = 0 ; i < cbData ; i ++ )
{
- thumbprint[i] = fingerprint[i];
+ pthumbprint[i] = fingerprint[i];
}
return thumbprint;
@@ -515,9 +521,10 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectP
CRYPT_BIT_BLOB publicKey = m_pCertContext->pCertInfo->SubjectPublicKeyInfo.PublicKey;
Sequence< sal_Int8 > key( publicKey.cbData ) ;
+ auto keyRange = asNonConstRange(key);
for( unsigned int i = 0 ; i < publicKey.cbData ; i++ )
{
- key[i] = *(publicKey.pbData + i) ;
+ keyRange[i] = *(publicKey.pbData + i) ;
}
return key;
diff --git a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
index c36de660df4e..c4d1c6113bf6 100644
--- a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
+++ b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
@@ -200,14 +200,15 @@ uno::Sequence< ::sal_Int8 > SAL_CALL OCipherContext::finalizeCipherContextAndDis
sal_Int32 nPaddingSize = m_nBlockSize - nSizeForPadding;
sal_Int32 nOldLastBlockLen = m_aLastBlock.getLength();
m_aLastBlock.realloc( nOldLastBlockLen + nPaddingSize );
+ auto pLastBlock = m_aLastBlock.getArray();
if ( nPaddingSize > 1 )
{
rtlRandomPool aRandomPool = rtl_random_createPool();
- rtl_random_getBytes( aRandomPool, m_aLastBlock.getArray() + nOldLastBlockLen, nPaddingSize - 1 );
+ rtl_random_getBytes( aRandomPool, pLastBlock + nOldLastBlockLen, nPaddingSize - 1 );
rtl_random_destroyPool ( aRandomPool );
}
- m_aLastBlock[m_aLastBlock.getLength() - 1] = static_cast< sal_Int8 >( nPaddingSize );
+ pLastBlock[m_aLastBlock.getLength() - 1] = static_cast< sal_Int8 >( nPaddingSize );
}
// finally should the last block be smaller than two standard blocks
diff --git a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx
index 5827c5f92272..e37a5473ceb8 100644
--- a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx
@@ -84,8 +84,9 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
otherNameProp.Name = OUString::createFromAscii(CERT_GetOidString(&current->name.OthName.oid));
Sequence< sal_Int8 > otherName( current->name.OthName.name.len ) ;
+ auto otherNameRange = asNonConstRange(otherName);
for( unsigned int r = 0; r < current->name.OthName.name.len ; r ++ )
- otherName[r] = *( current->name.OthName.name.data + r ) ;
+ otherNameRange[r] = *( current->name.OthName.name.data + r ) ;
otherNameProp.Value <<= otherName;
@@ -123,8 +124,9 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
m_Entries[i].Type = ExtAltNameType_IP_ADDRESS;
Sequence< sal_Int8 > ipAddress( current->name.other.len ) ;
+ auto ipAddressRange = asNonConstRange(ipAddress);
for( unsigned int r = 0; r < current->name.other.len ; r ++ )
- ipAddress[r] = *( current->name.other.data + r ) ;
+ ipAddressRange[r] = *( current->name.other.data + r ) ;
m_Entries[i].Value <<= ipAddress;
break;
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 94200051d57d..f6c35257f80f 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -263,7 +263,6 @@ void SecurityEnvironment_NssImpl::updateSlots()
Sequence< Reference < XCertificate > >
SecurityEnvironment_NssImpl::getPersonalCertificates()
{
- sal_Int32 length ;
std::vector< rtl::Reference<X509Certificate_NssImpl> > certsList ;
updateSlots();
@@ -299,17 +298,8 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
}
- length = certsList.size() ;
- if( length != 0 ) {
- int i = 0;
- Sequence< Reference< XCertificate > > certSeq( length ) ;
-
- for( const auto& rXCert : certsList ) {
- certSeq[i] = rXCert ;
- ++i;
- }
-
- return certSeq ;
+ if( certsList.size() != 0 ) {
+ return comphelper::containerToSequence<Reference< XCertificate >>(certsList) ;
}
return Sequence< Reference < XCertificate > > ();
@@ -488,9 +478,7 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::createCertificateFromAsci
if (certSize == 0)
return nullptr;
- Sequence< sal_Int8 > rawCert(certSize) ;
- for (int i = 0 ; i < certSize; ++i)
- rawCert[i] = *( chCert + i ) ;
+ Sequence< sal_Int8 > rawCert(comphelper::arrayToSequence<sal_Int8>(chCert, certSize)) ;
xmlFree( chCert ) ;
diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx
index 67956e018e88..2d52134344fb 100644
--- a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx
@@ -26,6 +26,7 @@
#include <pk11pub.h>
#include <sal/config.h>
+#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ref.hxx>
@@ -72,11 +73,8 @@ sal_Int16 SAL_CALL X509Certificate_NssImpl::getVersion() {
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getSerialNumber() {
if( m_pCert != nullptr && m_pCert->serialNumber.len > 0 ) {
- Sequence< sal_Int8 > serial( m_pCert->serialNumber.len ) ;
- for( unsigned int i = 0 ; i < m_pCert->serialNumber.len ; i ++ )
- serial[i] = *( m_pCert->serialNumber.data + i ) ;
-
- return serial ;
+ return comphelper::arrayToSequence<sal_Int8>(m_pCert->serialNumber.data,
+ m_pCert->serialNumber.len) ;
} else {
return css::uno::Sequence< sal_Int8 >();
}
@@ -158,11 +156,7 @@ css::util::DateTime SAL_CALL X509Certificate_NssImpl::getNotValidAfter() {
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getIssuerUniqueID() {
if( m_pCert != nullptr && m_pCert->issuerID.len > 0 ) {
- Sequence< sal_Int8 > issuerUid( m_pCert->issuerID.len ) ;
- for( unsigned int i = 0 ; i < m_pCert->issuerID.len ; i ++ )
- issuerUid[i] = *( m_pCert->issuerID.data + i ) ;
-
- return issuerUid ;
+ return comphelper::arrayToSequence<sal_Int8>(m_pCert->issuerID.data, m_pCert->issuerID.len) ;
} else {
return css::uno::Sequence< sal_Int8 >();
}
@@ -170,11 +164,8 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getIssuerUnique
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getSubjectUniqueID() {
if( m_pCert != nullptr && m_pCert->subjectID.len > 0 ) {
- Sequence< sal_Int8 > subjectUid( m_pCert->subjectID.len ) ;
- for( unsigned int i = 0 ; i < m_pCert->subjectID.len ; i ++ )
- subjectUid[i] = *( m_pCert->subjectID.data + i ) ;
-
- return subjectUid ;
+ return comphelper::arrayToSequence<sal_Int8>(m_pCert->subjectID.data,
+ m_pCert->subjectID.len) ;
} else {
return css::uno::Sequence< sal_Int8 >();
}
@@ -187,6 +178,7 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
for( len = 0, extns = m_pCert->extensions; *extns != nullptr; len ++, extns ++ ) ;
Sequence< Reference< XCertificateExtension > > xExtns( len ) ;
+ auto xExtnsRange = asNonConstRange(xExtns);
for( extns = m_pCert->extensions, len = 0; *extns != nullptr; extns ++, len ++ ) {
const SECItem id = (*extns)->id;
@@ -215,13 +207,13 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
{
rtl::Reference<SanExtensionImpl> pExtn = new SanExtensionImpl;
pExtn->setCertExtn(value, vlen, objid, objidlen, crit);
- xExtns[len] = pExtn ;
+ xExtnsRange[len] = pExtn ;
}
else
{
rtl::Reference<CertificateExtension_XmlSecImpl> pExtn = new CertificateExtension_XmlSecImpl;
pExtn->setCertExtn(value, vlen, objid, objidlen, crit);
- xExtns[len] = pExtn;
+ xExtnsRange[len] = pExtn;
}
}
@@ -283,12 +275,7 @@ css::uno::Reference< css::security::XCertificateExtension > SAL_CALL X509Certifi
css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getEncoded() {
if( m_pCert != nullptr && m_pCert->derCert.len > 0 ) {
- Sequence< sal_Int8 > rawCert( m_pCert->derCert.len ) ;
-
- for( unsigned int i = 0 ; i < m_pCert->derCert.len ; i ++ )
- rawCert[i] = *( m_pCert->derCert.data + i ) ;
-
- return rawCert ;
+ return comphelper::arrayToSequence<sal_Int8>(m_pCert->derCert.data, m_pCert->derCert.len) ;
} else {
return css::uno::Sequence< sal_Int8 >();
}
@@ -392,11 +379,7 @@ static css::uno::Sequence< sal_Int8 > getThumbprint(CERTCertificate const *pCert
rv = PK11_HashBuf(id, fingerprint, pCert->derCert.data, pCert->derCert.len);
if(rv == SECSuccess)
{
- Sequence< sal_Int8 > thumbprint( length ) ;
- for( int i = 0 ; i < length ; i ++ )
- thumbprint[i] = fingerprint[i];
-
- return thumbprint;
+ return comphelper::arrayToSequence<sal_Int8>(fingerprint, length);
}
}
return css::uno::Sequence< sal_Int8 >();
@@ -423,13 +406,7 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_NssImpl::getSubjectPubli
if ( spk.len>0)
{
- Sequence< sal_Int8 > key( spk.len ) ;
- for( unsigned int i = 0 ; i < spk.len ; i ++ )
- {
- key[i] = *( spk.data + i ) ;
- }
-
- return key ;
+ return comphelper::arrayToSequence<sal_Int8>(spk.data, spk.len) ;
}
}
diff --git a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
index c648865cae1d..1694e30c86a2 100644
--- a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
+++ b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
@@ -799,11 +799,12 @@ void SAL_CALL XMLDocumentWrapper_XmlSecImpl::startElement( const OUString& aName
{
sal_Int32 nLength = xAttribs->getLength();
uno::Sequence< css::xml::csax::XMLAttribute > aAttributes (nLength);
+ auto aAttributesRange = asNonConstRange(aAttributes);
for (int i = 0; i < nLength; ++i)
{
- aAttributes[i].sName = xAttribs->getNameByIndex(static_cast<short>(i));
- aAttributes[i].sValue =xAttribs->getValueByIndex(static_cast<short>(i));
+ aAttributesRange[i].sName = xAttribs->getNameByIndex(static_cast<short>(i));
+ aAttributesRange[i].sValue =xAttribs->getValueByIndex(static_cast<short>(i));
}
compressedStartElement(aName, aAttributes);