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 754018bd1 Bullet-proof IOUtils.copyRange(InputStream, long, 
OutputStream, int)
754018bd1 is described below

commit 754018bd11cfae20c3787633da4fd0c1f351a7f9
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Nov 13 17:13:15 2023 -0500

    Bullet-proof IOUtils.copyRange(InputStream, long, OutputStream, int)
---
 src/main/java/org/apache/commons/compress/utils/IOUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/utils/IOUtils.java 
b/src/main/java/org/apache/commons/compress/utils/IOUtils.java
index 15dfcc118..88b630545 100644
--- a/src/main/java/org/apache/commons/compress/utils/IOUtils.java
+++ b/src/main/java/org/apache/commons/compress/utils/IOUtils.java
@@ -165,7 +165,7 @@ public final class IOUtils {
         if (bufferSize < 1) {
             throw new IllegalArgumentException("bufferSize must be bigger than 
0");
         }
-        final byte[] buffer = new byte[(int) Math.min(bufferSize, len)];
+        final byte[] buffer = new byte[(int) Math.min(bufferSize, Math.max(0, 
len))];
         int n = 0;
         long count = 0;
         while (count < len && -1 != (n = input.read(buffer, 0, (int) 
Math.min(len - count, buffer.length)))) {

Reply via email to