commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r909366 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java
Date Fri, 12 Feb 2010 11:35:14 GMT
Author: bodewig
Date: Fri Feb 12 11:35:14 2010
New Revision: 909366

URL: http://svn.apache.org/viewvc?rev=909366&view=rev
Log:
improve error message for unparseable extra data.  COMPRESS-73

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.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=909366&r1=909365&r2=909366&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Feb 12 11:35:14 2010
@@ -23,7 +23,11 @@
   </properties>
   <body>
     <release version="1.1" date="as in SVN" description="Release 1.1">
-     <action type="add" issue="COMPRESS-95" date="2010-01-29"
+      <action type="fix" date="2010-02-12">
+        Improved exception message if the extra field data in ZIP
+        archives cannot be parsed.
+      </action>
+      <action type="add" issue="COMPRESS-95" date="2010-01-29"
               due-to="Joerg Bellmann">
         Improve ExceptionMessages in ArchiveStreamFactory
       </action>

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java?rev=909366&r1=909365&r2=909366&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
Fri Feb 12 11:35:14 2010
@@ -112,8 +112,12 @@
             ZipShort headerId = new ZipShort(data, start);
             int length = (new ZipShort(data, start + 2)).getValue();
             if (start + WORD + length > data.length) {
-                throw new ZipException("data starting at " + start
-                    + " is in unknown format");
+                throw new ZipException("bad extra field starting at "
+                                       + start + ".  Block length of "
+                                       + length + " bytes exceeds remaining"
+                                       + " data of "
+                                       + (data.length - start - WORD)
+                                       + " bytes.");
             }
             try {
                 ZipExtraField ze = createExtraField(headerId);

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java?rev=909366&r1=909365&r2=909366&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java
Fri Feb 12 11:35:14 2010
@@ -78,7 +78,8 @@
             fail("data should be invalid");
         } catch (Exception e) {
             assertEquals("message",
-                         "data starting at "+(4+aLocal.length)+" is in unknown format",
+                         "bad extra field starting at "+(4 + aLocal.length)
+                         + ".  Block length of 1 bytes exceeds remaining data of 0 bytes.",
                          e.getMessage());
         }
     }



Mime
View raw message