From: Hans-Christoph Steiner Date: Thu, 14 Dec 2017 09:58:02 +0000 (+0100) Subject: update: do not crash if AndroidManifest.xml in APK has invalid date X-Git-Tag: 1.0.0~28^2~1 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=42522c23c9dc16319eb66811467dca85bef227a4;hp=8f45796ecbb51303d32b5ae0136715400b4ce4ea;p=fdroidserver.git update: do not crash if AndroidManifest.xml in APK has invalid date This crash actually blocked a Janus exploit APK from being added to the repo, but crashing isn't really the appropriate way to do that. --- diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 15013347..782d18fc 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1355,10 +1355,13 @@ def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=Fal apkzip = zipfile.ZipFile(apkfile, 'r') manifest = apkzip.getinfo('AndroidManifest.xml') - if manifest.date_time[1] == 0: # month can't be zero - logging.debug(_('AndroidManifest.xml has no date')) - else: - common.check_system_clock(datetime(*manifest.date_time), apkfilename) + # 1980-0-0 means zeroed out, any other invalid date should trigger a warning + if (1980, 0, 0) != manifest.date_time[0:3]: + try: + common.check_system_clock(datetime(*manifest.date_time), apkfilename) + except ValueError as e: + logging.warning(_("{apkfilename}'s AndroidManifest.xml has a bad date: ") + .format(apkfilename=apkfile) + str(e)) # extract icons from APK zip file iconfilename = "%s.%s.png" % (apk['packageName'], apk['versionCode'])