Index: build/android/resource_sizes.py |
diff --git a/build/android/resource_sizes.py b/build/android/resource_sizes.py |
index 83542d350f83fb018095f12f4e1213fd4630c58d..1995d1eb630a10603c324f733b0cb5331a4a0f8b 100755 |
--- a/build/android/resource_sizes.py |
+++ b/build/android/resource_sizes.py |
@@ -16,6 +16,7 @@ import operator |
import optparse |
import os |
import re |
+import struct |
import sys |
import tempfile |
import zipfile |
@@ -34,6 +35,45 @@ with host_paths.SysPath(_GRIT_PATH): |
with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): |
import perf_tests_results_helper # pylint: disable=import-error |
+# Python had a bug in zipinfo parsing that triggers on ChromeModern.apk |
+# https://bugs.python.org/issue14315 |
+def _PatchedDecodeExtra(self): |
+ # Try to decode the extra field. |
+ extra = self.extra |
+ unpack = struct.unpack |
+ while len(extra) >= 4: |
+ tp, ln = unpack('<HH', extra[:4]) |
+ if tp == 1: |
+ if ln >= 24: |
+ counts = unpack('<QQQ', extra[4:28]) |
+ elif ln == 16: |
+ counts = unpack('<QQ', extra[4:20]) |
+ elif ln == 8: |
+ counts = unpack('<Q', extra[4:12]) |
+ elif ln == 0: |
+ counts = () |
+ else: |
+ raise RuntimeError, "Corrupt extra field %s"%(ln,) |
+ |
+ idx = 0 |
+ |
+ # ZIP64 extension (large files and/or large archives) |
+ if self.file_size in (0xffffffffffffffffL, 0xffffffffL): |
+ self.file_size = counts[idx] |
+ idx += 1 |
+ |
+ if self.compress_size == 0xFFFFFFFFL: |
+ self.compress_size = counts[idx] |
+ idx += 1 |
+ |
+ if self.header_offset == 0xffffffffL: |
+ self.header_offset = counts[idx] |
+ idx += 1 |
+ |
+ extra = extra[ln + 4:] |
+ |
+zipfile.ZipInfo._decodeExtra = ( # pylint: disable=protected-access |
+ _PatchedDecodeExtra) |
# Static initializers expected in official builds. Note that this list is built |
# using 'nm' on libchrome.so which results from a GCC official build (i.e. |