summaryrefslogtreecommitdiff
path: root/package/source
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-10-14 13:52:12 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2024-10-14 15:56:42 +0200
commit279f42fa8b19d4fe81c3bba4c7af21aa8ab135b9 (patch)
tree973debf72c9bb71ed11f60963ad59c110e88f3bd /package/source
parent23d7910c1e1fc41ab3b7b931cb91e007e09a4086 (diff)
tdf#163341 package: fix reading Zip64 produced by stream-write-ods
1. Accept 0xFFFF as nEndDisk/nEndDirDisk - the Zip APPNOTE says that values that don't fit into 16 bits SHOULD be 0xFFFF but it doesn't prohibit values that do fit (like, uhm, 0) to be written as 0xFFFF (regression from commit ca21cc985d57fffe7c834159b17c095206304994) 2. Fix misuse of o3tl::make_unsigned - it requires non-negative value, just do signed compare instead 3. Fix bad conversion from pointer to optional in ZipFile::readExtraFields() which effectively prevented the offset from being read (regression from commit efae4fc42d5fe3c0a69757226f38efc10d101194) Change-Id: Ib5e7776a30834e507b297fb28266b5489d1ab68d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174898 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'package/source')
-rw-r--r--package/source/zipapi/ZipFile.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 450a6795ce2d..39a9cc4fca50 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -1187,12 +1187,12 @@ std::tuple<sal_Int64, sal_Int64, sal_Int64> ZipFile::findCentralDirectory()
aGrabber.seek(nEndPos + 4);
sal_uInt16 const nEndDisk = aGrabber.ReadUInt16();
- if (nEndDisk != 0)
+ if (nEndDisk != 0 && nEndDisk != 0xFFFF)
{ // only single disk is supported!
throw ZipException(u"invalid end (disk)"_ustr );
}
sal_uInt16 const nEndDirDisk = aGrabber.ReadUInt16();
- if (nEndDirDisk != 0)
+ if (nEndDirDisk != 0 && nEndDisk != 0xFFFF)
{
throw ZipException(u"invalid end (directory disk)"_ustr );
}
@@ -1275,12 +1275,12 @@ std::tuple<sal_Int64, sal_Int64, sal_Int64> ZipFile::findCentralDirectory()
{
throw ZipException(u"inconsistent Zip/Zip64 end (entries)"_ustr);
}
- if (o3tl::make_unsigned(nEndDirSize) != sal_uInt32(-1)
+ if (nEndDirSize != -1
&& nEnd64DirSize != nEndDirSize)
{
throw ZipException(u"inconsistent Zip/Zip64 end (size)"_ustr);
}
- if (o3tl::make_unsigned(nEndDirOffset) != sal_uInt32(-1)
+ if (nEndDirOffset != -1
&& nEnd64DirOffset != nEndDirOffset)
{
throw ZipException(u"inconsistent Zip/Zip64 end (offset)"_ustr);
@@ -1554,7 +1554,7 @@ bool ZipFile::readExtraFields(MemoryByteGrabber& aMemGrabber, sal_Int16 nExtraLe
{
nCompressedSize = aMemGrabber.ReadUInt64();
nReadSize = 16;
- if (dataSize >= 24 && roOffset)
+ if (dataSize >= 24)
{
roOffset.emplace(aMemGrabber.ReadUInt64());
nReadSize = 24;