From 297783db951ee550de79901b4ed6c29735061541 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 23 Apr 2015 22:41:45 +0200 Subject: [PATCH] Reject invalid string in --date argument 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 [rlb@defaultvalue.org: adjust commit summary] Reviewed-by: Rob Browning Tested-by: Rob Browning --- lib/bup/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index bcaec1b..f1c6084 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -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: -- 2.39.2