commit a570d9f726473b47d48be4f912a8fa0c7bfd639f Author: Sebastian Hahn sebastian@torproject.org Date: Wed Feb 29 03:01:21 2012 +0100
Prevent crash on startup when reading Feb 29th in logs
During prepopulation of log entries, arm tries to parse the date that Tor gives it. Unfortunately Python is a little (read: very) silly and refuses to accept that February 29th can be a valid day when information about the year is missing. As a solution, we just pretend it is the year 2012 forever when parsing dates from logs (Tor doesn't add the year to its date information).
Fixes bug 5265, first reported by an anonymous user from IRC. --- src/cli/logPanel.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/cli/logPanel.py b/src/cli/logPanel.py index 179db9f..496fe86 100644 --- a/src/cli/logPanel.py +++ b/src/cli/logPanel.py @@ -302,8 +302,12 @@ def getLogFileEntries(runlevels, readLimit = None, addLimit = None, config = Non
# overwrites missing time parameters with the local time (ignoring wday # and yday since they aren't used) - eventTimeComp = list(time.strptime(timestamp, "%b %d %H:%M:%S")) - eventTimeComp[0] = currentLocalTime.tm_year + # Pretend the year is 2012, because 2012 is a leap year, and parsing a + # date with strptime fails if Feb 29th is passed without a year that's + # actually a leap year. We can't just use the current year, because we + # might be parsing old logs which didn't get rotated. + timestamp = "2012 " + timestamp + eventTimeComp = list(time.strptime(timestamp, "%Y %b %d %H:%M:%S")) eventTimeComp[8] = currentLocalTime.tm_isdst eventTime = time.mktime(eventTimeComp) # converts local to unix time