openzim / libzim

Reference implementation of the ZIM specification
https://download.openzim.org/release/libzim/
GNU General Public License v2.0
166 stars 49 forks source link

Libzim fails to check embeded zim file. #812

Open mgautierfr opened 1 year ago

mgautierfr commented 1 year ago

Zim file can be embedded in another file. We can open such a zim file with the fd Archive constructor

However, calling check on the such archive fails. This probably comes from the verify implementation (https://github.com/openzim/libzim/blob/main/src/fileimpl.cpp#L563-L604) which don't care of the initial offset in the fd.

Jaifroid commented 1 year ago

Sounds like ZIMception... (sorry, couldn't resit that 😉). Seriously, though, is this a realistic scenario (ZIM inside ZIM) that I need to be aware of and handle in the Kiwix JS backend?

kelson42 commented 1 year ago

@Jaifroid This is a scenario for custom apps utltimatively (ZIM file part of the Android app resource file). Not aware about an other one and actually wonder how @mgautierfr came to detect that bug.

mgautierfr commented 1 year ago

actually wonder how @mgautierfr came to detect that bug.

When working on the java wrapping and wanted to check with a embedded zim file. See : https://github.com/kiwix/java-libkiwix/blob/main/lib/src/test/test.java#L238-L239

Jaifroid commented 1 year ago

@Jaifroid This is a scenario for custom apps ultimately (ZIM file part of the Android app resource file). Not aware about an other one and actually wonder how @mgautierfr came to detect that bug.

Ah, OK, thanks.