From f3ff488fd4fb56f178ffbb7b3880dfafdd9d8e9c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 4 Aug 2020 21:29:47 +0200 Subject: loplugin:flatten in unotools Change-Id: I2fad16061bca6dc3e57926863e7a3b71947a8ade Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100139 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unotools/source/config/securityoptions.cxx | 74 +++++++++++++++--------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'unotools/source/config/securityoptions.cxx') diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx index d81517f255a0..36aa85b3ac8c 100644 --- a/unotools/source/config/securityoptions.cxx +++ b/unotools/source/config/securityoptions.cxx @@ -412,49 +412,49 @@ void SvtSecurityOptions_Impl::LoadAuthors() m_seqTrustedAuthors.realloc( 0 ); // first clear const Sequence< OUString > lAuthors = GetNodeNames( PROPERTYNAME_MACRO_TRUSTEDAUTHORS ); sal_Int32 c1 = lAuthors.getLength(); - if( c1 ) + if( !c1 ) + return; + + sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor + Sequence< OUString > lAllAuthors( c2 ); + + sal_Int32 i2 = 0; + OUString aSep( "/" ); + for( const auto& rAuthor : lAuthors ) { - sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor - Sequence< OUString > lAllAuthors( c2 ); + lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME; + ++i2; + lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER; + ++i2; + lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA; + ++i2; + } - sal_Int32 i2 = 0; - OUString aSep( "/" ); - for( const auto& rAuthor : lAuthors ) - { - lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME; - ++i2; - lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER; - ++i2; - lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA; - ++i2; - } + Sequence< Any > lValues = GetProperties( lAllAuthors ); + if( lValues.getLength() != c2 ) + return; - Sequence< Any > lValues = GetProperties( lAllAuthors ); - if( lValues.getLength() == c2 ) + std::vector< SvtSecurityOptions::Certificate > v; + SvtSecurityOptions::Certificate aCert( 3 ); + i2 = 0; + for( sal_Int32 i1 = 0; i1 < c1; ++i1 ) + { + lValues[ i2 ] >>= aCert[ 0 ]; + ++i2; + lValues[ i2 ] >>= aCert[ 1 ]; + ++i2; + lValues[ i2 ] >>= aCert[ 2 ]; + ++i2; + // Filter out TrustedAuthor entries with empty RawData, which + // would cause an unexpected std::bad_alloc in + // SecurityEnvironment_NssImpl::createCertificateFromAscii and + // have been observed in the wild (fdo#55019): + if( !aCert[ 2 ].isEmpty() ) { - std::vector< SvtSecurityOptions::Certificate > v; - SvtSecurityOptions::Certificate aCert( 3 ); - i2 = 0; - for( sal_Int32 i1 = 0; i1 < c1; ++i1 ) - { - lValues[ i2 ] >>= aCert[ 0 ]; - ++i2; - lValues[ i2 ] >>= aCert[ 1 ]; - ++i2; - lValues[ i2 ] >>= aCert[ 2 ]; - ++i2; - // Filter out TrustedAuthor entries with empty RawData, which - // would cause an unexpected std::bad_alloc in - // SecurityEnvironment_NssImpl::createCertificateFromAscii and - // have been observed in the wild (fdo#55019): - if( !aCert[ 2 ].isEmpty() ) - { - v.push_back( aCert ); - } - } - m_seqTrustedAuthors = comphelper::containerToSequence(v); + v.push_back( aCert ); } } + m_seqTrustedAuthors = comphelper::containerToSequence(v); } sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName ) -- cgit