dovecot-2.2: imap: Fixed potential crash if client disconnected ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 6 12:54:16 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/672350cdf509
changeset: 16936:672350cdf509
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 06 12:53:58 2013 +0200
description:
imap: Fixed potential crash if client disconnected during APPEND.

diffstat:

 src/imap/cmd-append.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r aa1aede0f7f2 -r 672350cdf509 src/imap/cmd-append.c
--- a/src/imap/cmd-append.c	Tue Nov 05 20:11:11 2013 +0200
+++ b/src/imap/cmd-append.c	Wed Nov 06 12:53:58 2013 +0200
@@ -60,7 +60,7 @@
 
 	str_printfa(str, "Disconnected in APPEND (%u msgs, %u secs",
 		    ctx->count, secs);
-	if (ctx->litinput != NULL) {
+	if (ctx->literal_size > 0) {
 		str_printfa(str, ", %"PRIuUOFF_T"/%"PRIuUOFF_T" bytes",
 			    lit_offset, ctx->literal_size);
 	}
@@ -74,6 +74,7 @@
 	struct client *client = cmd->client;
 	const char *reason;
 	bool finished;
+	uoff_t lit_offset;
 
 	i_assert(!client->destroyed);
 
@@ -83,7 +84,9 @@
 	switch (i_stream_read(client->input)) {
 	case -1:
 		/* disconnected */
-		reason = get_disconnect_reason(ctx, ctx->litinput->v_offset);
+		lit_offset = ctx->litinput == NULL ? 0 :
+			ctx->litinput->v_offset;
+		reason = get_disconnect_reason(ctx, lit_offset);
 		cmd_append_finish(cmd->context);
 		/* Reset command so that client_destroy() doesn't try to call
 		   cmd_append_continue_message() anymore. */


More information about the dovecot-cvs mailing list