From: Guido van Rossum Date: Wed, 23 Dec 1998 21:58:38 +0000 (+0000) Subject: Avoid crash in parsedate_tz() on certain invalid dates -- when the X-Git-Tag: v1.5.2b2~504 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99e11315360d700ca7abb251e3a6774de6f46be1;p=python Avoid crash in parsedate_tz() on certain invalid dates -- when the field assumed to be the time is in fact the year, the resulting list doesn't have enough items, and this isn't checked for. Return None instead. --- diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 2e97ef4daf..b466fae3a6 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -800,8 +800,10 @@ def parsedate_tz(data): if len(tm) == 2: [thh, tmm] = tm tss = '0' - else: + elif len(tm) == 3: [thh, tmm, tss] = tm + else: + return None try: yy = string.atoi(yy) dd = string.atoi(dd)