Open rombust opened 1 day ago
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 (Configurations2/
and Thumbnails/
.
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)
package/source/zippackage/ZipPackage.cxx
32cad89 package: ZipPackage: add additional check for entries STORED with by Michael Stahl · 3 months ago
In function they added below, the "entry STORED with data descriptor but not encrypted" exception is thrown.
void ZipPackage::checkZipEntriesWithDD()
{
if (!m_bForceRecovery)
{
ZipEnumeration entries{m_pZipFile->entries()};
while (entries.hasMoreElements())
{
ZipEntry const& rEntry{*entries.nextElement()};
if ((rEntry.nFlag & 0x08) != 0 && rEntry.nMethod == STORED)
{
uno::Reference<XPropertySet> xStream;
getByHierarchicalName(rEntry.sPath) >>= xStream;
if (!xStream->getPropertyValue("WasEncrypted").get<bool>())
{
SAL_INFO("package", "entry STORED with data descriptor but not encrypted: \"" << rEntry.sPath << "\"");
throw ZipIOException(
THROW_WHERE
"entry STORED with data descriptor but not encrypted");
}
}
}
}
}
I will investigate. Thank you
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.