From: Timo Sirainen Date: Fri, 3 Apr 2009 16:41:56 +0000 (-0400) Subject: IMAP: Don't allow APPEND to specify INTERNALDATE more than 2 hours into future. X-Git-Tag: 1.2.rc1~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b485e05b2a505b09c387a6f6505ea510e9018aa;p=thirdparty%2Fdovecot%2Fcore.git IMAP: Don't allow APPEND to specify INTERNALDATE more than 2 hours into future. --HG-- branch : HEAD --- diff --git a/src/imap/cmd-append.c b/src/imap/cmd-append.c index 8042e55d7c..390a01ff8b 100644 --- a/src/imap/cmd-append.c +++ b/src/imap/cmd-append.c @@ -12,6 +12,12 @@ #include +/* Don't allow internaldates to be too far in the future. At least with Maildir + they can cause problems with incremental backups since internaldate is + stored in file's mtime. But perhaps there are also some other reasons why + it might not be wanted. */ +#define INTERNALDATE_MAX_FUTURE_SECS (2*3600) + struct cmd_append_context { struct client *client; struct client_command_context *cmd; @@ -321,6 +327,13 @@ static bool cmd_append_continue_parsing(struct client_command_context *cmd) return cmd_append_cancel(ctx, nonsync); } + if (internal_date != (time_t)-1 && + internal_date > ioloop_time + INTERNALDATE_MAX_FUTURE_SECS) { + /* the client specified a time in the future, set it to now. */ + internal_date = (time_t)-1; + timezone_offset = 0; + } + if (ctx->msg_size == 0) { /* no message data, abort */ client_send_tagline(cmd, "NO Can't save a zero byte message.");