Date validation must check for 32-bit width. Don't use assert to check.
authorBryan O'Sullivan <bos@serpentine.com>
Sat, 03 Sep 2005 23:51:53 -0700
changeset 1197 8deb69818e4b
parent 1196 3738e85ead07
child 1198 66f7d3946109
Date validation must check for 32-bit width. Don't use assert to check.
mercurial/changelog.py
--- a/mercurial/changelog.py	Sat Sep 03 23:28:15 2005 -0700
+++ b/mercurial/changelog.py	Sat Sep 03 23:51:53 2005 -0700
@@ -33,10 +33,13 @@
                   user=None, date=None):
         if date:
             # validate explicit (probably user-specified) date and
-            # time zone offset
+            # time zone offset. values must fit in signed 32 bits for
+            # current 32-bit linux runtimes.
             when, offset = map(int, date.split(' '))
-            time.localtime(when)
-            assert abs(offset) < 43200, 'bad time zone offset: %d' % offset
+            if abs(when) > 0x7fffffff:
+                raise ValueError('date exceeds 32 bits: %d' % when)
+            if abs(offset) >= 43200:
+                raise ValueError('impossible time zone offset: %d' % offset)
         else:
             if time.daylight: offset = time.altzone
             else: offset = time.timezone