classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: minor ZipFile improvement


From: Anthony Green
Subject: [cp-patches] Patch: minor ZipFile improvement
Date: Wed, 14 Sep 2005 18:06:09 -0700

Another patch to an unlikely problem.  This just makes sure we've
actually read all 4 bytes of the magic word.  It also quiets FindBugs
which was complaining about how we were ignoring the read result.

Ok?

AG



2005-09-14  Anthony Green  <address@hidden>

        * java/util/zip/ZipFile.java (checkZipFile): Make sure we read the
        4 byte magic number.  Not strictly necessary, but quiets FindBugs.

Index: java/util/zip/ZipFile.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/zip/ZipFile.java,v
retrieving revision 1.26
diff -u -r1.26 ZipFile.java
--- java/util/zip/ZipFile.java  13 Sep 2005 22:19:15 -0000      1.26
+++ java/util/zip/ZipFile.java  15 Sep 2005 00:22:27 -0000
@@ -144,9 +144,9 @@
   private void checkZipFile() throws IOException, ZipException
   {
     byte[] magicBuf = new byte[4];
-    raf.read(magicBuf);
 
-    if (readLeInt(magicBuf, 0) != LOCSIG)
+    if (raf.read(magicBuf) != 4
+       || readLeInt(magicBuf, 0) != LOCSIG)
       {
        raf.close();
        throw new ZipException("Not a valid zip file");






reply via email to

[Prev in Thread] Current Thread [Next in Thread]