-
-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibreOffice zip file validation changes #817
Comments
It's been a while, but my recollection of the equivalent issue with Office files, which also use zip behind the scenes, is that the exact layout of the zipfile needs to be maintained. So things like the order the files are stored in the zip will matter. Whether they are compressed or stored and whether the file is stored streamed or not streamed. In this case the two things that stand out are the order of the files and the presence of the directory entries ( Whether one of these is the root-case here is difficult to tell definitively without knowing ho Libre handles zip files -- I just know that the equivalent Office file were very picky about the structure of the zipfile. You could also try running zipdetails on the before & after zipfiles to see what other internal metadata is different. |
Thank you. I will have a look at that. "zipdetails" will be helpful. I have tracked down to when LibreOffice changed (downloading and debugging source)
In function they added below, the "entry STORED with data descriptor but not encrypted" exception is thrown.
I will investigate. Thank you |
I have created a LibreOffice bug report for comments. Bug 163818 - Opening ODG file is reported to be corrupted when created by 3rd party software . |
I still haven't located the problem. A lot of red herrings and going around in circles! (This usually means that I am missing something obvious) A workaround: Instead of using "mz_zip_writer_copy_from_reader(zip_writer, zip_reader);" The following code fixes the issue:
|
I use the minizip-ng library to modify "content.xml" in a LibreOffice Draw document, in my C++ application
Since LibreOffice "LibreOffice_24.8.2_Win_x86-64", when opening the document, I get "The file "example.odg" is corrupt and therefore cannot be opened. LibreOffice can try to repair the file." . When the document is "repaired", the file opens as expected.
This is also in the daily development build v24.8 - 2024-11-06_09.10.55.
It works in LibreOffice 7.6.7.2
To simplify the debugging, I can recreate the issue as follows (with setup and error checking removed)
The example.odg was created by LibreOffice.
If I use "minizip.exe" to extract the files, then "minizip.exe" to compress the files into "example_minizip_fixed.odg", my code works.
Looking at the list of these files, they differ. Notice the Libreoffice version (example.odg), "Attribs" are set to 0
Looking into
The external_fa is set to 0, therefore "mz_zip_attrib_is_dir" will never return MZ_OK. Thus the hash is always calculated.
Note, mz_zip_writer_copy_from_reader also uses mz_zip_attrib_is_dir .
I tried forcing the correct Attribs, thinking this was the source of the problem. However LibreOffice still reported the file is corrupt.
Has anyone else seen this?
Observation 1) minizip.exe stores "Configurations2/" name in the above example. I am unsure if that's an issue.
Observation 2) The output.odg file that my code (using mz_zip_writer_copy_from_reader) creates. Using minizip.exe, If I extract it, then recompress it. LibreOffice will open the file without issues.
The text was updated successfully, but these errors were encountered: