From 70dd47f0dfef3373d7062d5aadab3ad7c2d69e24 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 17 Jun 2020 17:22:40 +0100 Subject: [PATCH] Fail check-boot-jars if boot jar contains 0 .class files Protect against an invalid boot jar, e.g. one containing .dex files is used instead of .class files. Test: add a prebuilt for framework-tethering Run `m check-boot-jars` with the first fix from https://r.android.com/1341756 and the build fails due to no .class files because a dex jar is used. Run `m check-boot-jars` with all fixeds from https://r.android.com/1341756 and the build works. Bug: 158304459 Bug: 159112414 Merged-In: I0e8ebd318312949bc58ba7a5c89f9e265b8bedf2 Change-Id: I0e8ebd318312949bc58ba7a5c89f9e265b8bedf2 (cherry picked from 92d41de8f225d70616ac3ab9a4723bf019e60c52) --- core/tasks/check_boot_jars/check_boot_jars.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/tasks/check_boot_jars/check_boot_jars.py b/core/tasks/check_boot_jars/check_boot_jars.py index 6904a772a2..cf4ef27825 100755 --- a/core/tasks/check_boot_jars/check_boot_jars.py +++ b/core/tasks/check_boot_jars/check_boot_jars.py @@ -49,8 +49,10 @@ def CheckJar(allow_list_path, jar): if p.returncode != 0: return False items = stdout.split() + classes = 0 for f in items: if f.endswith('.class'): + classes += 1 package_name = os.path.dirname(f) package_name = package_name.replace('/', '.') if not package_name or not allow_list_re.match(package_name): @@ -58,6 +60,9 @@ def CheckJar(allow_list_path, jar): ' not in the allow list %s of packages allowed on the bootclasspath.' % (jar, f, package_name, allow_list_path)) return False + if classes == 0: + print >> sys.stderr, ('Error: %s does not contain any class files.' % jar) + return False return True