]> granicus.if.org Git - python/commitdiff
Avoid crash in parsedate_tz() on certain invalid dates -- when the
authorGuido van Rossum <guido@python.org>
Wed, 23 Dec 1998 21:58:38 +0000 (21:58 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 23 Dec 1998 21:58:38 +0000 (21:58 +0000)
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.

Lib/rfc822.py

index 2e97ef4daf274546f8800f6795ebca7fcd70407d..b466fae3a61907d76c6e8a02fb434ad2ce18d589 100644 (file)
@@ -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)