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 2024/01/14 15:04:27 UTC
(commons-compress) branch master updated: ArchiveInputStream.BoundedInputStream.read() incorrectly adds 1 for EOF to the bytes read count
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 50e90a45e ArchiveInputStream.BoundedInputStream.read() incorrectly adds 1 for EOF to the bytes read count
50e90a45e is described below
commit 50e90a45e1e0c36811fc47316de84d6a199c0336
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 14 10:04:22 2024 -0500
ArchiveInputStream.BoundedInputStream.read() incorrectly adds 1 for EOF
to the bytes read count
---
src/changes/changes.xml | 1 +
.../commons/compress/archivers/zip/ZipArchiveInputStream.java | 9 +++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fded109b3..c3f07bacf 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" issue="COMPRESS-657" dev="ggregory" due-to="Sebastian Schuberth, Gary Gregory">Fix TAR directory entries being misinterpreted as files #460.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate unused method FileNameUtils.getBaseName(String).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate unused method FileNameUtils.getExtension(String).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">ArchiveInputStream.BoundedInputStream.read() incorrectly adds 1 for EOF to the bytes read count.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ZipFile.builder(), add ZipFile.Builder, deprecated constructors.</action>
<!-- UPDATE -->
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index bd4a965ec..e46a44e9f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -108,10 +108,11 @@ public class ZipArchiveInputStream extends ArchiveInputStream<ZipArchiveEntry> i
return -1;
}
final int result = in.read();
- // TODO what if the result is -1?
- pos++;
- count(1);
- current.bytesReadFromStream++;
+ if (result != -1) {
+ pos++;
+ count(1);
+ current.bytesReadFromStream++;
+ }
return result;
}