Skip to content

Identify corrupted entries before reading their data #261

Answered by gildas-lormeau
ksidlauskas asked this question in Q&A
Discussion options

You must be logged in to vote

The local header of an entry in a zip file must begin with 0x504b0304 (in big-endian). The error you mentioned is thrown when this value is not found (cf. chapter 4.3.7 in the spec).

if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
}

This test cannot be run when listing entries because the ZipReader#getEntries method would run much slower, especially when retrieving the zip content with a HttpRangeReader instance or when reading a zip file with hundreds of entries.

Note however that you can abort the execution of Entry#getData if you want to t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ksidlauskas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants