This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: ZipEntry(String) with length > 65535


Hi,

The following fixes a deficiency in ZipEntry as pointed out by a bug
report against GNU Classpath. The zip format doesn't support very large
file names. There is also a new Mauve test that passes with this fix.

2003-02-21  Mark Wielaard  <mark at klomp dot org>
  
       * java/util/zip/ZipEntry.java (ZipEntry(String)): When name is bigger
       then 65535 chars throw IllegalArgumentException.

I am committing this to branch and mainline.

Cheers,

Mark
Index: java/util/zip/ZipEntry.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/zip/ZipEntry.java,v
retrieving revision 1.15
diff -u -r1.15 ZipEntry.java
--- java/util/zip/ZipEntry.java	3 Dec 2002 22:06:31 -0000	1.15
+++ java/util/zip/ZipEntry.java	21 Feb 2003 12:49:24 -0000
@@ -84,11 +84,15 @@
    * Creates a zip entry with the given name.
    * @param name the name. May include directory components separated
    * by '/'.
+   *
+   * @exception NullPointerException when name is null.
+   * @exception IllegalArgumentException when name is bigger then 65535 chars.
    */
   public ZipEntry(String name)
   {
-    if (name == null)
-      throw new NullPointerException();
+    int length = name.length();
+    if (length > 65535)
+      throw new IllegalArgumentException("name length is " + length);
     this.name = name;
   }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]