Bug 163341 - Zip64 ODS sheet not opening
Summary: Zip64 ODS sheet not opening
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
24.8.2.1 release
Hardware: All All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:25.2.0 target:24.8.3 target:24...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-07 15:17 UTC by Michal Charemza
Modified: 2024-11-08 12:15 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Python script to create a Zip64 test.ods file (337 bytes, text/plain)
2024-10-07 15:18 UTC, Michal Charemza
Details
ODS file in Zip64 format (1.33 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-10-08 05:00 UTC, Michal Charemza
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Charemza 2024-10-07 15:17:23 UTC
Description:
If I make an ODS spreadsheet using the Python package stream_write_ods https://github.com/uktrade/stream-write-ods, but using its (new) use_zip_64=True flag, then LibreOffice reports the file as corrupt.

This is in spite of the file validating as valid ODF at https://odfvalidator.org/, and validating as a valid ZIP file using `unzip -t`.

Passing use_zip_64=False into stream_write_ods results in a file that opens in LibreOffice without error.

Full disclosure: I am a maintainer of stream_write_ods, as well as its underlying zip library. Of course, there _could_ be a problem at the ZIP level (ZIPs are not easy!), but so far I've not found it

Steps to Reproduce:
1. Install Python (e.g. Python 3.11)

2. Install the latest version of stream-write-ods

pip install stream-write-ods==0.0.25

3. Create a Zip64 ODS file using the following Python script:

from stream_write_ods import stream_write_ods

ods_chunks = stream_write_ods((
    (
        'Sheet 1 name', ('col_1_name', 'col_2_name'), (
            ('Value A', 'Value B'),
            ('Value C', 'Value D'),
        )
    ),
), use_zip_64=True)

with open('test.ods', 'wb') as f:
    for chunk in ods_chunks:
        f.write(chunk)

4. Attempt to open the file in LibreOffice

Actual Results:
The following message appears:

----------------

The file 'test.ods' is corrupt and therefore cannot be opened. LibreOffice can try to repair the file.

The corruption could be the result of document manipulation or of structural document damage due to data transmission.

We recommend that you do not trust the content of the repaired document.
Execution of macros is disabled for this document.

Should LibreOffice repair the file?


Expected Results:
The files opens as a spreadsheet without error


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.8.2.1 (AARCH64) / LibreOffice Community
Build ID: 0f794b6e29741098670a3b95d60478a65d05ef13
CPU threads: 8; OS: macOS 14.5; UI render: Skia/Raster; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: threaded
Comment 1 Michal Charemza 2024-10-07 15:18:59 UTC
Created attachment 196950 [details]
Python script to create a Zip64 test.ods file
Comment 2 Michal Charemza 2024-10-08 05:00:21 UTC
Created attachment 196958 [details]
ODS file in Zip64 format

An ODS file using Zip64 created by the attached Python script
Comment 3 Julien Nabet 2024-10-08 18:55:57 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.

Renaming test.ods into test.zip then
using:
zip -F test.zip --out test2.zip work
and finally renaming test2.zip into test2.ods, it works.

Michael: thought you might be interested in this one considering the work you did on Zip management.
Comment 4 Commit Notification 2024-10-14 13:57:43 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/279f42fa8b19d4fe81c3bba4c7af21aa8ab135b9

tdf#163341 package: fix reading Zip64 produced by stream-write-ods

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Michael Stahl (allotropia) 2024-10-14 14:05:08 UTC
the ODF validator is using Apache Commons Compress which abstracts away lots of interesting things that can't be checked...

due to the lack of error reporting infrastructure in the sfx2 module, the problems that are detected by LO cannot be displayed to the user, you need a debug build and run with SAL_LOG="+INFO.package+WARN" to see them...

i don't see anything obviously wrong with the attachment, replacing the "disk numbers" with 0xFFFF is funny but allowed, and the bad handling of 64-bit offset later on is an indication that there aren't enough Zip64 unit tests...

fixed on master
Comment 6 Michael Stahl (allotropia) 2024-10-14 14:08:07 UTC
(In reply to Michael Stahl (allotropia) from comment #5)
> replacing the
> "disk numbers" with 0xFFFF is funny but allowed

btw, please don't send me your ODF file split across 64k+1 floppy disks, the multi-disk zips are out of scope for LO :)
Comment 7 Commit Notification 2024-10-14 19:26:51 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/b9160c7f95c54028a6948c4f3aff113bd29df686

tdf#163341 package: fix reading Zip64 produced by stream-write-ods

It will be available in 24.8.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2024-10-14 19:27:58 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/9e95415b24c4127873b1b121402cc5356d6116b6

tdf#163341 package: fix reading Zip64 produced by stream-write-ods

It will be available in 24.2.8.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Julien Nabet 2024-10-14 20:23:53 UTC
On pc Debian x86-64 with master sources updated today, I confirm sheet can be opened.
Thank you Michael!
Comment 10 Michal Charemza 2024-10-15 07:02:47 UTC
Ah thank you for this!

One thing on the change, should it be using the 0xFFFF value of disk number as an indicator that it should look at the corresponding Zip64 value, and then only erroring out if _that_ value isn’t zero?
Comment 11 Commit Notification 2024-10-28 13:07:13 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-24-2-7":

https://git.libreoffice.org/core/commit/cf87f49f7e9633b6369f2c1c6bb85efb24679212

tdf#163341 package: fix reading Zip64 produced by stream-write-ods

It will be available in 24.2.7.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.