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 <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-09-07 18:21:45 +02:00 committed by Nicolas Sebrecht
parent 135f8c45cf
commit 5cbec30b3e
1 changed files with 4 additions and 0 deletions

View File

@ -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]],