< prev index next >

src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java

Print this page

        

@@ -1064,13 +1064,18 @@
                 zerror("invalid CEN header (encrypted entry)");
             if (method != METHOD_STORED && method != METHOD_DEFLATED)
                 zerror("invalid CEN header (unsupported compression method: " + method + ")");
             if (pos + CENHDR + nlen > limit)
                 zerror("invalid CEN header (bad header size)");
-            byte[] name = Arrays.copyOfRange(cen, pos + CENHDR, pos + CENHDR + nlen);
+            int startIndex = pos + CENHDR;
+            int endIndex = startIndex + nlen;
+            startIndex = ((nlen > 0) && (char)cen[startIndex] == '/') ? startIndex + 1 : startIndex;
+            byte[] name = Arrays.copyOfRange(cen, startIndex, endIndex);
+            if(name.length > 0){
             IndexNode inode = new IndexNode(name, pos);
             inodes.put(inode, inode);
+            }
             // skip ext and comment
             pos += (CENHDR + nlen + elen + clen);
         }
         if (pos + ENDHDR != cen.length) {
             zerror("invalid CEN header (bad header size)");
< prev index next >