commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r741092 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress: archivers/tar/ archivers/zip/ compressors/bzip2/
Date Thu, 05 Feb 2009 12:45:24 GMT
Author: bodewig
Date: Thu Feb  5 12:45:23 2009
New Revision: 741092

URL: http://svn.apache.org/viewvc?rev=741092&view=rev
Log:
merge revision 741089 from Ant trunk - fix for various findbugs issues - [SANDBOX-246]

Modified:
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/
  (props changed)
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/
  (props changed)
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
  (contents, props changed)
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
  (contents, props changed)

Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/
------------------------------------------------------------------------------
    svn:mergeinfo = /ant/core/trunk/src/main/org/apache/tools/tar:741089

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java
Thu Feb  5 12:45:23 2009
@@ -218,8 +218,13 @@
                         + numToSkip + " bytes");
             }
 
-            if (numToSkip > 0) {
-                skip(numToSkip);
+            while (numToSkip > 0) {
+                long skipped = skip(numToSkip);
+                if (skipped <= 0) {
+                    throw new RuntimeException("failed to skip current tar"
+                                               + " entry");
+                }
+                numToSkip -= skipped;
             }
 
             readBuf = null;

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java
Thu Feb  5 12:45:23 2009
@@ -305,7 +305,7 @@
 
                 wOffset += numToWrite;
                 assemLen += numToWrite;
-                numToWrite -= numToWrite;
+                numToWrite = 0;
             }
         }
 

Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb  5 12:45:23 2009
@@ -1 +1 @@
-/ant/core/trunk/src/main/org/apache/tools/zip:738844,739300
+/ant/core/trunk/src/main/org/apache/tools/zip:738844,739300,741089

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java
Thu Feb  5 12:45:23 2009
@@ -334,4 +334,14 @@
         return type | (mode & PERM_MASK);
     }
 
+    public Object clone() {
+        try {
+            AsiExtraField cloned = (AsiExtraField) super.clone();
+            cloned.crc = new CRC32();
+            return cloned;
+        } catch (CloneNotSupportedException cnfe) {
+            // impossible
+            throw new RuntimeException(cnfe);
+        }
+    }
 }

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
Thu Feb  5 12:45:23 2009
@@ -57,7 +57,7 @@
      */
     public void setCentralDirectoryData( final byte[] centralData )
     {
-        m_centralData = centralData;
+        m_centralData = copy(centralData);
     }
 
        /**
@@ -77,7 +77,7 @@
      */
     public void setLocalFileDataData( final byte[] localData )
     {
-        m_localData = localData;
+        m_localData = copy(localData);
     }
 
     /**
@@ -89,7 +89,7 @@
     {
         if( m_centralData != null )
         {
-            return m_centralData;
+            return copy(m_centralData);
         }
         return getLocalFileDataData();
     }
@@ -125,7 +125,7 @@
      */
     public byte[] getLocalFileDataData()
     {
-        return m_localData;
+        return copy(m_localData);
     }
 
     /**
@@ -153,4 +153,13 @@
         System.arraycopy( buffer, offset, fileData, 0, length );
         setLocalFileDataData( fileData );
     }
+
+    private static byte[] copy(byte[] from) {
+        if (from != null) {
+            byte[] to = new byte[from.length];
+            System.arraycopy(from, 0, to, 0, to.length);
+            return to;
+        }
+        return null;
+    }
 }

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Thu Feb  5 12:45:23 2009
@@ -344,7 +344,15 @@
 
             nameMap.put(ze.getName(), ze);
 
-            archive.skipBytes(extraLen);
+            int lenToSkip = extraLen;
+            while (lenToSkip > 0) {
+                int skipped = archive.skipBytes(lenToSkip);
+                if (skipped <= 0) {
+                    throw new RuntimeException("failed to skip extra data in"
+                                               + " central directory");
+                }
+                lenToSkip -= skipped;
+            }            
 
             byte[] comment = new byte[commentLen];
             archive.readFully(comment);
@@ -460,7 +468,15 @@
             int fileNameLen = ZipShort.getValue(b);
             archive.readFully(b);
             int extraFieldLen = ZipShort.getValue(b);
-            archive.skipBytes(fileNameLen);
+            int lenToSkip = fileNameLen;
+            while (lenToSkip > 0) {
+                int skipped = archive.skipBytes(lenToSkip);
+                if (skipped <= 0) {
+                    throw new RuntimeException("failed to skip file name in"
+                                               + " local file header");
+                }
+                lenToSkip -= skipped;
+            }            
             byte[] localExtraData = new byte[extraFieldLen];
             archive.readFully(localExtraData);
             ze.setExtra(localExtraData);

Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb  5 12:45:23 2009
@@ -1 +1 @@
-/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738844,738853,739300
+/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738844,738853,739300,741089

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
Thu Feb  5 12:45:23 2009
@@ -146,4 +146,13 @@
     public int hashCode() {
         return (int) value;
     }
+
+    public Object clone() {
+        try {
+            return (ZipLong) super.clone();
+        } catch (CloneNotSupportedException cnfe) {
+            // impossible
+            throw new RuntimeException(cnfe);
+        }
+    }
 }

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java
Thu Feb  5 12:45:23 2009
@@ -132,4 +132,13 @@
     public int hashCode() {
         return value;
     }
+
+    public Object clone() {
+        try {
+            return (ZipShort) super.clone();
+        } catch (CloneNotSupportedException cnfe) {
+            // impossible
+            throw new RuntimeException(cnfe);
+        }
+    }
 }

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=741092&r1=741091&r2=741092&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
Thu Feb  5 12:45:23 2009
@@ -614,7 +614,7 @@
                 }
 
                 if (ge > gs && nPart != nGroups && nPart != 1
-                    && ((nGroups - nPart) % 2 == 1)) {
+                    && ((nGroups - nPart) % 2 != 0)) {
                     aFreq -= mtfFreq[ge];
                     ge--;
                 }
@@ -984,9 +984,7 @@
             b = t;
         }
         if (b > c) {
-            t = b;
             b = c;
-            c = t;
         }
         if (a > b) {
             b = a;
@@ -1031,7 +1029,7 @@
 
             med = med3(block[zptr[lo] + d + 1],
                        block[zptr[hi            ] + d  + 1],
-                       block[zptr[(lo + hi) >> 1] + d + 1]);
+                       block[zptr[(lo + hi) >>> 1] + d + 1]);
 
             unLo = ltLo = lo;
             unHi = gtHi = hi;

Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Feb  5 12:45:23 2009
@@ -0,0 +1 @@
+/ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java:741089



Mime
View raw message