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 2015/05/08 21:11:27 UTC

svn commit: r1678430 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java

Author: bodewig
Date: Fri May  8 19:11:27 2015
New Revision: 1678430

URL: http://svn.apache.org/r1678430
Log:
COMPRESS-314 read group/user ids > 0x80000000 from (posix) tars

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1678430&r1=1678429&r2=1678430&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri May  8 19:11:27 2015
@@ -54,7 +54,11 @@ breaks backwards compatibility for code
 This also changes the superclass of ZCompressorInputStream.    
 ">
 
-      <action issue="COMPRESS-315" type="add" date="2015-05-06">
+      <action issue="COMPRESS-314" type="fix" date="2015-05-08">
+        TarArchiveInputStream can now read entries with group or
+        user ids &gt; 0x80000000.
+      </action>
+      <action issue="COMPRESS-315" type="fix" date="2015-05-06">
         TarArchiveOutputStream can now write entries with group or
         user ids &gt; 0x80000000.
       </action>

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1678430&r1=1678429&r2=1678430&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Fri May  8 19:11:27 2015
@@ -498,11 +498,11 @@ public class TarArchiveInputStream exten
             } else if ("linkpath".equals(key)){
                 currEntry.setLinkName(val);
             } else if ("gid".equals(key)){
-                currEntry.setGroupId(Integer.parseInt(val));
+                currEntry.setGroupId(Long.parseLong(val));
             } else if ("gname".equals(key)){
                 currEntry.setGroupName(val);
             } else if ("uid".equals(key)){
-                currEntry.setUserId(Integer.parseInt(val));
+                currEntry.setUserId(Long.parseLong(val));
             } else if ("uname".equals(key)){
                 currEntry.setUserName(val);
             } else if ("size".equals(key)){

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java?rev=1678430&r1=1678429&r2=1678430&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java Fri May  8 19:11:27 2015
@@ -235,6 +235,27 @@ public class TarArchiveInputStreamTest {
         }
     }
 
+    @Test
+    public void shouldReadBigGid() throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        TarArchiveOutputStream tos = new TarArchiveOutputStream(bos);
+        tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
+        TarArchiveEntry t = new TarArchiveEntry("name");
+        t.setGroupId(4294967294l);
+        t.setSize(1);
+        tos.putArchiveEntry(t);
+        tos.write(30);
+        tos.closeArchiveEntry();
+        tos.close();
+        byte[] data = bos.toByteArray();
+        ByteArrayInputStream bis = new ByteArrayInputStream(data);
+        TarArchiveInputStream tis =
+            new TarArchiveInputStream(bis);
+        t = tis.getNextTarEntry();
+        assertEquals(4294967294l, t.getLongGroupId());
+        tis.close();
+    }
+
     private TarArchiveInputStream getTestStream(String name) {
         return new TarArchiveInputStream(
                 TarArchiveInputStreamTest.class.getResourceAsStream(name));