]> git.saurik.com Git - backport.git/commitdiff
Add support for protecting against bug #10227498. master v0.9.7
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 6 Nov 2013 23:23:04 +0000 (15:23 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 6 Nov 2013 23:23:04 +0000 (15:23 -0800)
src/com/saurik/backport/Hook.java

index ae62a812af503c8c1522e104ba35cb32421ebe1d..8dab649e949fda07842fff53ade6a9db03708468 100644 (file)
@@ -108,6 +108,21 @@ public class Hook {
     }
 
     private static void fixZipFile$getInputStream() {
+        final Field ZipEntry$compressedSize = scanField(ZipEntry.class, "compressedSize");
+        if (ZipEntry$compressedSize == null)
+            return;
+        ZipEntry$compressedSize.setAccessible(true);
+
+        final Field ZipEntry$compressionMethod = scanField(ZipEntry.class, "compressionMethod");
+        if (ZipEntry$compressionMethod == null)
+            return;
+        ZipEntry$compressionMethod.setAccessible(true);
+
+        final Field ZipEntry$size = scanField(ZipEntry.class, "size");
+        if (ZipEntry$size == null)
+            return;
+        ZipEntry$size.setAccessible(true);
+
         final Field ZipEntry$nameLen = scanField(ZipEntry.class, "nameLen", "nameLength");
         if (ZipEntry$nameLen == null)
             return;
@@ -152,6 +167,10 @@ public class Hook {
                             throw new ZipException("bug #9695860 [" + thiz.getName() + "]");
                     }
 
+                    if (ZipEntry$compressionMethod.getInt(entry) == ZipEntry.STORED)
+                        if (ZipEntry$compressedSize.getLong(entry) != ZipEntry$size.getLong(entry))
+                            throw new ZipException("bug #10227498 [" + thiz.getName() + "]");
+
                     return invoke(thiz, args);
                 }
             }