[PATCH 2/3] Sanity check for maxage setting
Sebastian Spaeth
Sebastian at SSpaeth.de
Wed Sep 7 17:21:45 BST 2011
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 <Sebastian at SSpaeth.de>
---
offlineimap/folder/IMAP.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index cee9aa0..502ac83 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -131,6 +131,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]],
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list