summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-08-27 17:16:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-08-27 20:33:50 +0200
commit2730ae520da2c47ac1cabaa3ddcc43359aae5875 (patch)
tree36024612ecc74d206d67e505807cc55bb5314e9c /oox
parent5be3b44a87fafebe56840eadd983020f57e566c4 (diff)
ofz#24934 practically infinite loop on eof
Change-Id: Iaa6121f3a0088978c57718610bc9baf9bcfe6fee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101489 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/crypto/DocumentDecryption.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/oox/source/crypto/DocumentDecryption.cxx b/oox/source/crypto/DocumentDecryption.cxx
index 45b820a89302..c566426267ff 100644
--- a/oox/source/crypto/DocumentDecryption.cxx
+++ b/oox/source/crypto/DocumentDecryption.cxx
@@ -117,14 +117,14 @@ bool DocumentDecryption::readEncryptionInfo()
SAL_WARN_IF(aEntryCount != 1, "oox", "DataSpaceMap contains more than one entry. Some content may be skipped");
// Read each DataSpaceMapEntry (MS-OFFCRYPTO 2.1.6.1)
- for (sal_uInt32 i = 0; i < aEntryCount; i++)
+ for (sal_uInt32 i = 0; i < aEntryCount && !aDataSpaceStream.isEof(); i++)
{
// entryLen unused for the moment
aDataSpaceStream.skip(sizeof(sal_uInt32));
// Read each DataSpaceReferenceComponent (MS-OFFCRYPTO 2.1.6.2)
sal_uInt32 aReferenceComponentCount = aDataSpaceStream.readuInt32();
- for (sal_uInt32 j = 0; j < aReferenceComponentCount; j++)
+ for (sal_uInt32 j = 0; j < aReferenceComponentCount && !aDataSpaceStream.isEof(); j++)
{
// Read next reference component
// refComponentType unused for the moment
@@ -139,6 +139,12 @@ bool DocumentDecryption::readEncryptionInfo()
sDataSpaceName = aDataSpaceStream.readUnicodeArray(aDataSpaceNameLength / 2);
aDataSpaceStream.skip((4 - (aDataSpaceNameLength & 3)) & 3); // Skip padding
}
+
+ if (aDataSpaceStream.isEof())
+ {
+ SAL_WARN("oox", "EOF on parsing DataSpaceMapEntry table");
+ return false;
+ }
}
else
{