You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/02/15 20:03:20 UTC

[commons-compress] branch master updated: Fix FileBands misusing InputStream#read(byte[]) (#360)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new 14493492 Fix FileBands misusing InputStream#read(byte[]) (#360)
14493492 is described below

commit 14493492edf675483b1f81d488eba1e77ea156bf
Author: Una <me...@unascribed.com>
AuthorDate: Wed Feb 15 12:03:14 2023 -0800

    Fix FileBands misusing InputStream#read(byte[]) (#360)
---
 .../java/org/apache/commons/compress/harmony/unpack200/FileBands.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java
index fdd41c60..be5c5128 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/FileBands.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
 
 import org.apache.commons.compress.harmony.pack200.Codec;
 import org.apache.commons.compress.harmony.pack200.Pack200Exception;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * Parses the file band headers (not including the actual bits themselves). At the end of this parse call, the input
@@ -82,7 +83,7 @@ public class FileBands extends BandSet {
             // TODO This breaks if file_size > 2^32. Probably an array is
             // not the right choice, and we should just serialize it here?
             fileBits[i] = new byte[size];
-            final int read = in.read(fileBits[i]);
+            final int read = IOUtils.readFully(in, fileBits[i]);
             if (size != 0 && read < size) {
                 throw new Pack200Exception("Expected to read " + size + " bytes but read " + read);
             }