summaryrefslogtreecommitdiffstats
path: root/comphelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-02-06 21:07:19 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-02-07 09:03:48 +0000
commit3ec9bccaabb4a2998c9bd29992af1d1880b284d8 (patch)
tree049ccb4431d544771338ff6d2c13e2a6ce7dcba1 /comphelper
parentUse rtl::Reference (diff)
downloadcore-3ec9bccaabb4a2998c9bd29992af1d1880b284d8.tar.gz
core-3ec9bccaabb4a2998c9bd29992af1d1880b284d8.zip
silence coverity#1027865 Out-of-bounds access
and coverity#1027864 Change-Id: Ic3d1b91ef77ab3510c7428b7135dd9f249d56b4b
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index 9d312a341f58..72b8636cbe7b 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -284,7 +284,18 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateStd97Key( const sal_uInt16 pPassData[16], const uno::Sequence< sal_Int8 >& aDocId )
{
uno::Sequence< sal_Int8 > aResultKey;
- if ( pPassData[0] && aDocId.getLength() == 16 )
+
+ if ( aDocId.getLength() == 16 )
+ aResultKey = GenerateStd97Key(pPassData, (const sal_uInt8*)aDocId.getConstArray());
+
+ return aResultKey;
+}
+
+// ============================================================================
+/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateStd97Key( const sal_uInt16 pPassData[16], const sal_uInt8 pDocId[16] )
+{
+ uno::Sequence< sal_Int8 > aResultKey;
+ if ( pPassData[0] )
{
sal_uInt8 pKeyData[64];
memset( pKeyData, 0, sizeof(pKeyData) );
@@ -312,7 +323,7 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
for ( nInd = 0; nInd < 16; nInd++ )
{
rtl_digest_updateMD5( hDigest, pKeyData, 5 );
- rtl_digest_updateMD5( hDigest, (const sal_uInt8*)aDocId.getConstArray(), aDocId.getLength() );
+ rtl_digest_updateMD5( hDigest, pDocId, 16 );
}
// Update digest with padding.
@@ -334,6 +345,7 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
return aResultKey;
}
+
// ============================================================================
/*static*/ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > DocPasswordHelper::requestAndVerifyDocPassword(