Handle BadZipFile

This commit is contained in:
Jochen Sprickerhof 2022-05-02 13:37:08 +02:00 committed by Hans-Christoph Steiner
parent 925cdbe542
commit c80fdd5ce8

View file

@ -115,6 +115,7 @@ def get_embedded_classes(apkfile, depth=0):
class_regex = re.compile(r'classes.*\.dex')
classes = set()
try:
with TemporaryDirectory() as tmp_dir, zipfile.ZipFile(apkfile, 'r') as apk_zip:
for info in apk_zip.infolist():
# apk files can contain apk files, again
@ -126,6 +127,8 @@ def get_embedded_classes(apkfile, depth=0):
apk_zip.extract(info, tmp_dir)
run = common.SdkToolsPopen(["dexdump", '{}/{}'.format(tmp_dir, info.filename)])
classes = classes.union(set(re.findall(r'[A-Z]+((?:\w+\/)+\w+)', run.output)))
except zipfile.BadZipFile as ex:
return {_('Problem with ZIP file: %s, error %s') % (apkfile, ex)}
return classes