Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E1835106E3 for ; Tue, 10 Dec 2013 12:41:13 +0000 (UTC) Received: (qmail 72906 invoked by uid 500); 10 Dec 2013 12:41:11 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 72463 invoked by uid 500); 10 Dec 2013 12:41:08 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 72333 invoked by uid 99); 10 Dec 2013 12:41:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Dec 2013 12:41:08 +0000 Date: Tue, 10 Dec 2013 12:41:08 +0000 (UTC) From: "Ilja Pavkovic (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COMPRESS-249) TarArchiveInputStream does not properly read from underlying InputStream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COMPRESS-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13844238#comment-13844238 ] Ilja Pavkovic commented on COMPRESS-249: ---------------------------------------- ah, didn't know that > TarArchiveInputStream does not properly read from underlying InputStream > ------------------------------------------------------------------------ > > Key: COMPRESS-249 > URL: https://issues.apache.org/jira/browse/COMPRESS-249 > Project: Commons Compress > Issue Type: Bug > Components: Archivers > Affects Versions: 1.6 > Reporter: Ilja Pavkovic > Priority: Critical > Fix For: 1.7 > > > 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: > {code:title=TarArchiveInputStream.java|borderStyle=solid} > 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; > } > {code} -- This message was sent by Atlassian JIRA (v6.1.4#6159)