]> arthur.barton.de Git - bup.git/commitdiff
Reject invalid string in --date argument
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 23 Apr 2015 20:41:45 +0000 (22:41 +0200)
committerRob Browning <rlb@defaultvalue.org>
Fri, 24 Apr 2015 00:47:33 +0000 (19:47 -0500)
As parse_date_or_fatal() currently uses atof(), which just returns 0
if the string isn't a valid number, it can never actually be fatal
and will just use "1970-01-01 00:00:00" as the time if the string is
specified wrong.

Fix that by using float() directly so ValueError() is raised.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
[rlb@defaultvalue.org: adjust commit summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py

index bcaec1bf2daaab2201b2df43701b4c65f00f9b5f..f1c6084e5528a18ffdefa8e0dc808f982bf607c1 100644 (file)
@@ -827,7 +827,7 @@ def parse_date_or_fatal(str, fatal):
     """Parses the given date or calls Option.fatal().
     For now we expect a string that contains a float."""
     try:
-        date = atof(str)
+        date = float(str)
     except ValueError, e:
         raise fatal('invalid date format (should be a float): %r' % e)
     else: