Skip to content

fix(streamingUnzip): avoid detection of incorrect ZIP signature#275

Open
cyfung1031 wants to merge 1 commit into
101arrowz:masterfrom
cyfung1031:fix/unzip-streaming/001
Open

fix(streamingUnzip): avoid detection of incorrect ZIP signature#275
cyfung1031 wants to merge 1 commit into
101arrowz:masterfrom
cyfung1031:fix/unzip-streaming/001

Conversation

@cyfung1031
Copy link
Copy Markdown

@cyfung1031 cyfung1031 commented May 30, 2026

(Although the code is generated by AI but since 101arrowz do not like AI paragraphs so I write the following)

This is to solve the current design limit of streaming Unzip - causing issue #243.

When it scan the ZIP signatures like 0x8074B50, 0x4034B50, 0x2014B50, etc, it will believe this is end of file.

but this is incorrect since the compressed file might also contain such bytes by chance.

now the field "b" is added to represent "compressed bytes flushed so far for the current data-descriptor entry"

Then using this.b + candidateEndOffset to check whether the compression data matches descriptor, rather than just trusting the ZIP signature bytes.

( A real boundary is always preceded by a data descriptor whose csize field must equal the bytes consumed so far. )

btw z = oc == -2 && 8 is for zip64 data descriptors detection. So that it can check with the 64-bit size as well.


if you still don't like AI coding, just take it as a reference and do it yourself.
The coding isn't changed too much and you can read.


In addition

@cyfung1031
Copy link
Copy Markdown
Author

cyfung1031 commented May 31, 2026

because #235 is due to the streaming Unzip mixed up the ZIP signatures of the stored zip files and the one it is working on.

@cyfung1031
Copy link
Copy Markdown
Author

because #208 is due to the wrong detection of EOL due to the ZIP signature detection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant