changeset 8906:3c33885a717a HEAD

IMAP: Don't allow APPEND to specify INTERNALDATE more than 2 hours into future.
author Timo Sirainen <tss@iki.fi>
date Fri, 03 Apr 2009 12:41:56 -0400
parents b567f5f42b3d
children 9c82d97a5431
files src/imap/cmd-append.c
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-append.c	Fri Apr 03 12:35:02 2009 -0400
+++ b/src/imap/cmd-append.c	Fri Apr 03 12:41:56 2009 -0400
@@ -12,6 +12,12 @@
 
 #include <sys/time.h>
 
+/* 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 @@
 		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.");