Description
TarArchiveInputStream reads header with its protected function readRecord(). This code improperly assumes that is.read(buf) always fills the whole buffer. This assumption is wrong. A proper implementation needs to call read multiple times until all bytes are read:
TarArchiveInputStream.java
protected byte[] readRecord() throws IOException { byte[] record = new byte[recordSize]; // start change // int readNow = is.read(buf); int readNow = 0; while(readNow < recordSize){ int bytesRead = is.read(record,0, recordSize - readNow); if(bytesRead == -1) { break; } readNow += bytesRead; } // end change count(readNow); if (readNow != recordSize) { return null; } return record; }
Attachments
Issue Links
- duplicates
-
COMPRESS-245 TarArchiveInputStream#getNextTarEntry returns null prematurely
- Closed
- is broken by
-
COMPRESS-234 Patch: TAR InputStream Huge Speed Improvements
- Resolved