Add support for what I had previously called bug B. v0.9.3
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 1 Aug 2013 01:24:40 +0000 (18:24 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 1 Aug 2013 01:24:40 +0000 (18:24 -0700)
src/com/saurik/backport/Hook.java

index 1744455726fe6242fc1c55e184c6b713c7e71ec4..d1eb9504a0634e315172b28950fdbf2686881c91 100644 (file)
@@ -105,6 +105,11 @@ public class Hook {
     }
 
     private static void fixZipFile$getInputStream() {
+        final Field ZipEntry$nameLen = scanField(ZipEntry.class, "nameLen", "nameLength");
+        if (ZipEntry$nameLen == null)
+            return;
+        ZipEntry$nameLen.setAccessible(true);
+
         final Field ZipFile$mRaf = scanField(ZipFile.class, "mRaf", "raf");
         if (ZipFile$mRaf == null)
             return;
@@ -134,7 +139,12 @@ public class Hook {
                         if ((raf.readShort() & 0x0080) != 0)
                             throw new ZipException("bug #9695860 [" + thiz.getName() + "]");
 
-                        raf.skipBytes(20);
+                        raf.skipBytes(18);
+
+                        int length = raf.readShort() & 0xffff;
+                        if (length != ZipEntry$nameLen.getInt(entry))
+                            throw new ZipException("bug #sauriks [" + thiz.getName() + "]");
+
                         if ((raf.readShort() & 0x0080) != 0)
                             throw new ZipException("bug #9695860 [" + thiz.getName() + "]");
                     }