From 5cbec30b3ea2ef8abd8555630842ff4ebdbc5e03 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 7 Sep 2011 18:21:45 +0200 Subject: [PATCH] Sanity check for maxage setting If maxage is set too large, we would even SEARCH for negative years. With devastating results. So implement some sanity check and err out in case the year does not make sense. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 339f271..f3d1ad8 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -133,6 +133,10 @@ class IMAPFolder(BaseFolder): if(maxage != -1): #find out what the oldest message is that we should look at oldest_struct = time.gmtime(time.time() - (60*60*24*maxage)) + if oldest_struct[0] < 1900: + raise OfflineImapError("maxage setting led to year %d. " + "Abort syncing." % oldest_struct[0], + OfflineImapError.ERROR.REPO) search_cond += "SINCE %02d-%s-%d" % ( oldest_struct[2], MonthNames[oldest_struct[1]],