offset calculation was broken
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/compress/trunk@760017 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
index e137678..1aa9fca 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
@@ -111,19 +111,17 @@
public int read() throws IOException {
final int ret = input.read();
- offset++;
+ offset += (ret > 0 ? 1 : 0);
return ret;
}
public int read(byte b[]) throws IOException {
- final int ret = read(b, 0, b.length);
- offset = offset + b.length;
- return ret;
+ return read(b, 0, b.length);
}
public int read(byte[] b, int off, int len) throws IOException {
final int ret = this.input.read(b, off, len);
- offset = offset + off;
+ offset += (ret > 0 ? ret : 0);
return ret;
}