Bug 61381 - PushbackInputStreams passed to ZipHelper may not hold 8 bytes
Summary: PushbackInputStreams passed to ZipHelper may not hold 8 bytes
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: OPC (show other bugs)
Version: 3.17-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-04 01:55 UTC by Kenzie Togami
Modified: 2017-08-11 20:49 UTC (History)
1 user (show)



Attachments
Example (356 bytes, text/plain)
2017-08-04 01:55 UTC, Kenzie Togami
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kenzie Togami 2017-08-04 01:55:33 UTC
Created attachment 35200 [details]
Example

ZipHelper tries to be efficient when checking the header by reusing PushbackInputStreams that are given as input, but these streams may not hold the 8 bytes that are pushed back, and can cause an exception.

Testable example is attached.

Workaround: Wrap InputStreams in BufferedInputStream before passing them to anything that uses ZipHelper.

Solutions:
- always create a new PushbackInputStream
- stop using PushbackInputStream and switch to mark/reset + BufferedInputStream
Comment 1 Andreas Beeker 2017-08-06 17:20:16 UTC
Thanks for pointing this out.

I'm currently replacing the PushbackInputStream calls (option 2) and refactor the file magic checks in one spot.
Comment 2 Andreas Beeker 2017-08-11 20:49:23 UTC
patched via r1804854