commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r758846 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
Date Thu, 26 Mar 2009 20:46:31 GMT
Author: sebb
Date: Thu Mar 26 20:46:31 2009
New Revision: 758846

URL: http://svn.apache.org/viewvc?rev=758846&view=rev
Log:
COMPRESS-55 Don't attempt to set mode zero. Print error if mode 0 found not in trailer.

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=758846&r1=758845&r2=758846&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
Thu Mar 26 20:46:31 2009
@@ -321,7 +321,10 @@
         }
 
         ret.setInode(readAsciiLong(8, 16));
-        ret.setMode(readAsciiLong(8, 16));
+        long mode = readAsciiLong(8, 16);
+        if (mode != 0){ // mode is initialised to 0
+            ret.setMode(mode);
+        }
         ret.setUID(readAsciiLong(8, 16));
         ret.setGID(readAsciiLong(8, 16));
         ret.setNumberOfLinks(readAsciiLong(8, 16));
@@ -333,7 +336,12 @@
         ret.setRemoteDeviceMin(readAsciiLong(8, 16));
         long namesize = readAsciiLong(8, 16);
         ret.setChksum(readAsciiLong(8, 16));
-        ret.setName(readCString((int) namesize));
+        String name = readCString((int) namesize);
+        ret.setName(name);
+        if (mode == 0 && !name.equals(CPIO_TRAILER)){
+            // TODO - change this to throw
+            new IOException("Mode 0 only allowed in the trailer. Found: "+name).printStackTrace();
+        }
         pad(ret.getHeaderSize() + namesize, 4);
 
         return ret;



Mime
View raw message