node-unzipper icon indicating copy to clipboard operation
node-unzipper copied to clipboard

Handling 'extra data' at end of payload

Open ajohnson-ventera opened this issue 5 years ago • 5 comments

Some of the zip files we receive include (as 7zip warns) 'extra data at the end of the payload'. This extra data doesn't seem to affect winRAR or 7zip's ability to extract the files though.

However when I run it through the 'normal' unzipper.Parse() pipe, the process just hangs and doesn't throw an error. When I run it through unzipper.Open.s3(), it does throw an error for image

It doesn't seem to get to the same code location when running through unzipper.Parse(), and as I said just hangs instead of emitting an error. Is there any way to get the unzipper to emit an error when this happens instead?

I can't provide a sample upload unfortunately, but hopefully this makes sense.

ajohnson-ventera avatar Jan 14 '20 20:01 ajohnson-ventera

We will have to investigate how to fix the Parse method to behave appropriately. Currently the code for Parse and Open are separate, but at some point those should be merged as they share much of the same functionality.

The open methods allow you to specify tailSize in options. The tailSize is basically the number of bytes to inspect away from the end of the file to locate the Central Directory. If you set tailSize high enough, the central directory should hopefully parse properly, even with the extra stuff at the end.

Please let me know if the tailSize works - also feel free to take a stab at a PR for the parse method :)

ZJONSSON avatar Jan 14 '20 21:01 ZJONSSON

I see, yeah I can add a large enough tailSize to capture it. I think we are okay rejecting it anyway though.

I tried digging in on the Parse side for a while earlier, but I didn't find anything in the amount of time I had to spend on it. I'll try to take another look when I can if you don't fix it first.

ajohnson-ventera avatar Jan 14 '20 21:01 ajohnson-ventera

Sounds good, I would really appreciate it if you find a solution.

ZJONSSON avatar Jan 15 '20 15:01 ZJONSSON

Hello, I fixed same error (Error: FILE_ENDED) with PR #209.

kinolaev avatar Jul 08 '20 14:07 kinolaev

Hello @ZJONSSON, can you please review my PR #209?

kinolaev avatar Apr 14 '21 20:04 kinolaev