Bug 1565314 - use is_tarfile() check before is_zipfile() in mozinstall; r=ahal
authorMike Shal <mshal@mozilla.com>
Thu, 11 Jul 2019 19:49:03 +0000
changeset 482460 c28bc7d0b078d7c5f6f9f7b2fa559ea58aa2f581
parent 482459 bacec7b3bfde7f19c8ff08b882cf70bf2b54dfe1
child 482461 224e533c8f87a037e388e18ef16611f784d3cb6c
push id89789
push usermshal@mozilla.com
push dateThu, 11 Jul 2019 20:59:39 +0000
treeherderautoland@c28bc7d0b078 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1565314, 1552672
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1565314 - use is_tarfile() check before is_zipfile() in mozinstall; r=ahal Similar to bug 1552672, very rarely is_zipfile() can return True on a tarfile if the tarfile happens to contain a magic four byte sequence at the right location in the file. By checking for is_zipfile() first, we try to unzip the tar file and then fail. Instead we can call is_tarfile() first, which is more robust, and call is_zipfile() last. Differential Revision: https://phabricator.services.mozilla.com/D37765
testing/mozbase/mozfile/mozfile/mozfile.py
--- a/testing/mozbase/mozfile/mozfile/mozfile.py
+++ b/testing/mozbase/mozfile/mozfile/mozfile.py
@@ -92,20 +92,20 @@ def extract(src, dest=None):
     assert os.path.exists(src), "'%s' does not exist" % src
 
     if dest is None:
         dest = os.path.dirname(src)
     elif not os.path.isdir(dest):
         os.makedirs(dest)
     assert not os.path.isfile(dest), "dest cannot be a file"
 
-    if zipfile.is_zipfile(src):
+    if tarfile.is_tarfile(src):
+        namelist = extract_tarball(src, dest)
+    elif zipfile.is_zipfile(src):
         namelist = extract_zip(src, dest)
-    elif tarfile.is_tarfile(src):
-        namelist = extract_tarball(src, dest)
     else:
         raise Exception("mozfile.extract: no archive format found for '%s'" %
                         src)
 
     # namelist returns paths with forward slashes even in windows
     top_level_files = [os.path.join(dest, name.rstrip('/')) for name in namelist
                        if len(name.rstrip('/').split('/')) == 1]