Skip to content
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 data descriptor validation #830

Open
rombust opened this issue Nov 20, 2024 · 0 comments
Open

LibreOffice data descriptor validation #830

rombust opened this issue Nov 20, 2024 · 0 comments

Comments

@rombust
Copy link

rombust commented Nov 20, 2024

Since LibreOffice 24.8.2, they have changed the validation of their zip files.

When we use minizip-ng to recreate an LibreOffice document by using mz_zip_writer_copy_from_reader() or manually via mz_zip_writer_entry_write()

Opening the document in LibreOffice, we 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)

The LibreOffice function is in core/package/source/zippackage/ZipPackage.cxx "void ZipPackage::checkZipEntriesWithDD()". This throws an exception: "entry STORED with data descriptor"

To fix this: After opening the zip file (mz_zip_writer_open_file), set an internal minizip flag:


	void* writer_zip_handle = nullptr;
	err = mz_zip_writer_get_zip_handle(zip_writer, &writer_zip_handle);
	if (err == MZ_OK)
		mz_zip_set_data_descriptor(writer_zip_handle, 0);

This sets the use of data descriptor flag when writing zip entries.

mz_zip_writer_copy_from_reader() / mz_zip_writer_entry_open() now works as expected with LibreOffice files.

I don't know the details of why this is required.

For reference, see my initial LibreOffice bug report. https://bugs.documentfoundation.org/show_bug.cgi?id=163818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant