changeset 1197:8deb69818e4b

Date validation must check for 32-bit width. Don't use assert to check.
author Bryan O'Sullivan <bos@serpentine.com>
date Sat, 03 Sep 2005 23:51:53 -0700
parents 3738e85ead07
children 66f7d3946109
files mercurial/changelog.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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