You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2017/06/17 19:48:12 UTC

[1/5] commons-compress git commit: COMPRESS-411 ensure we really set the most sig byte when length is 8

Repository: commons-compress
Updated Branches:
  refs/heads/master 8c3201bbd -> 4be9979b4


COMPRESS-411 ensure we really set the most sig byte when length is 8


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/6b2bd2df
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/6b2bd2df
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/6b2bd2df

Branch: refs/heads/master
Commit: 6b2bd2df127be522a18d044980e84a8b638f25b7
Parents: 8c3201b
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 17 21:45:04 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 21:45:04 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/compress/archivers/tar/TarUtils.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b2bd2df/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index f95bbf3..c0dac4c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -503,8 +503,8 @@ public class TarUtils {
         }
         if (negative) {
             val ^= max - 1;
-            val |= 0xff << bits;
             val++;
+            val |= 0xffl << bits;
         }
         for (int i = offset + length - 1; i >= offset; i--) {
             buf[i] = (byte) val;


[4/5] commons-compress git commit: COMPRESS-411 actually use formatLongBinary

Posted by bo...@apache.org.
COMPRESS-411 actually use formatLongBinary


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/02735ad7
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/02735ad7
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/02735ad7

Branch: refs/heads/master
Commit: 02735ad7e6313515a846bc15bcc89cf254f8161f
Parents: 137aa57
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 17 21:47:10 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 21:47:10 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/compress/archivers/tar/TarUtils.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/02735ad7/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 39ce5c1..d132d9d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -484,8 +484,9 @@ public class TarUtils {
 
         if (length < 9) {
             formatLongBinary(value, buf, offset, length, negative);
+        } else {
+            formatBigIntegerBinary(value, buf, offset, length, negative);
         }
-        formatBigIntegerBinary(value, buf, offset, length, negative);
 
         buf[offset] = (byte) (negative ? 0xff : 0x80);
         return offset + length;


[2/5] commons-compress git commit: COMPRESS-411 Math.abs is dangerous

Posted by bo...@apache.org.
COMPRESS-411 Math.abs is dangerous


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/2c8892a2
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/2c8892a2
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/2c8892a2

Branch: refs/heads/master
Commit: 2c8892a206c9374b0cde6fce72299b0fe630f3a0
Parents: 6b2bd2d
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 17 21:46:25 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 21:46:25 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/compress/archivers/tar/TarUtils.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/2c8892a2/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index c0dac4c..4e99a20 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -496,8 +496,8 @@ public class TarUtils {
                                          final boolean negative) {
         final int bits = (length - 1) * 8;
         final long max = 1l << bits;
-        long val = Math.abs(value);
-        if (val >= max) {
+        long val = Math.abs(value); // Long.MIN_VALUE stays Long.MIN_VALUE
+        if (val < 0 || val >= max) {
             throw new IllegalArgumentException("Value " + value +
                 " is too large for " + length + " byte field.");
         }


[5/5] commons-compress git commit: COMPRESS-411 clearer formulation of the same test

Posted by bo...@apache.org.
COMPRESS-411 clearer formulation of the same test


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/4be9979b
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/4be9979b
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/4be9979b

Branch: refs/heads/master
Commit: 4be9979b45ceadc50dc24607884d34613fead1f5
Parents: 02735ad
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 17 21:47:43 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 21:47:43 2017 +0200

----------------------------------------------------------------------
 .../org/apache/commons/compress/archivers/tar/TarUtilsTest.java   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/4be9979b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
index a4ef25b..87f6b27 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
@@ -160,7 +160,8 @@ public class TarUtilsTest {
         checkRoundTripOctalOrBinary(1, length);
         checkRoundTripOctalOrBinary(TarConstants.MAXSIZE, length); // will need binary format
         checkRoundTripOctalOrBinary(-1, length); // will need binary format
-        checkRoundTripOctalOrBinary(0xff00000000000001l, length);
+        checkRoundTripOctalOrBinary(0xffffffffffffffl, length);
+        checkRoundTripOctalOrBinary(-0xffffffffffffffl, length);
     }
 
     // Check correct trailing bytes are generated


[3/5] commons-compress git commit: add an extra sanity check

Posted by bo...@apache.org.
add an extra sanity check


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/137aa57f
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/137aa57f
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/137aa57f

Branch: refs/heads/master
Commit: 137aa57f9291b5f390de740266042587cfede7ce
Parents: 2c8892a
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 17 21:46:53 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 21:46:53 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/compress/archivers/tar/TarUtils.java | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/137aa57f/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 4e99a20..39ce5c1 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -519,6 +519,10 @@ public class TarUtils {
         final BigInteger val = BigInteger.valueOf(value);
         final byte[] b = val.toByteArray();
         final int len = b.length;
+        if (len > length - 1) {
+            throw new IllegalArgumentException("Value " + value +
+                " is too large for " + length + " byte field.");
+        }
         final int off = offset + length - len;
         System.arraycopy(b, 0, buf, off, len);
         final byte fill = (byte) (negative ? 0xff : 0);