dovecot-2.1: imap: Memory leak fixes for invalid parameter handl...

dovecot at dovecot.org dovecot at dovecot.org
Fri Sep 30 18:54:11 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/1fd1321e55f4
changeset: 13565:1fd1321e55f4
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 30 19:02:31 2011 +0300
description:
imap: Memory leak fixes for invalid parameter handling.

diffstat:

 src/imap/cmd-copy.c         |   4 +++-
 src/imap/cmd-expunge.c      |  10 ++++++----
 src/imap/cmd-store.c        |   5 ++++-
 src/imap/imap-search-args.c |   2 ++
 4 files changed, 15 insertions(+), 6 deletions(-)

diffs (77 lines):

diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/cmd-copy.c
--- a/src/imap/cmd-copy.c	Fri Sep 30 18:53:09 2011 +0300
+++ b/src/imap/cmd-copy.c	Fri Sep 30 19:02:31 2011 +0300
@@ -106,8 +106,10 @@
 	if (ret <= 0)
 		return ret < 0;
 
-	if (client_open_save_dest_box(cmd, mailbox, &destbox) < 0)
+	if (client_open_save_dest_box(cmd, mailbox, &destbox) < 0) {
+		mail_search_args_unref(&search_args);
 		return TRUE;
+	}
 
 	t = mailbox_transaction_begin(destbox,
 				      MAILBOX_TRANSACTION_FLAG_EXTERNAL |
diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/cmd-expunge.c
--- a/src/imap/cmd-expunge.c	Fri Sep 30 18:53:09 2011 +0300
+++ b/src/imap/cmd-expunge.c	Fri Sep 30 19:02:31 2011 +0300
@@ -23,15 +23,17 @@
 			       struct mail_search_args *search_args)
 {
 	struct client *client = cmd->client;
+	int ret;
 
-	if (imap_expunge(client->mailbox, search_args == NULL ? NULL :
-			 search_args->args) < 0) {
+	ret = imap_expunge(client->mailbox, search_args == NULL ? NULL :
+			   search_args->args);
+	if (search_args != NULL)
+		mail_search_args_unref(&search_args);
+	if (ret < 0) {
 		client_send_storage_error(cmd,
 					  mailbox_get_storage(client->mailbox));
 		return TRUE;
 	}
-	if (search_args != NULL)
-		mail_search_args_unref(&search_args);
 
 	client->sync_seen_deletes = FALSE;
 	client->sync_seen_expunges = FALSE;
diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/cmd-store.c
--- a/src/imap/cmd-store.c	Fri Sep 30 18:53:09 2011 +0300
+++ b/src/imap/cmd-store.c	Fri Sep 30 19:02:31 2011 +0300
@@ -149,10 +149,13 @@
 
 	memset(&ctx, 0, sizeof(ctx));
 	ctx.cmd = cmd;
-	if (!store_parse_args(&ctx, ++args))
+	if (!store_parse_args(&ctx, ++args)) {
+		mail_search_args_unref(&search_args);
 		return TRUE;
+	}
 
 	if (client->mailbox_examined) {
+		mail_search_args_unref(&search_args);
 		if (ctx.max_modseq < (uint64_t)-1)
 			reply = "NO CONDSTORE failed: Mailbox is read-only.";
 		else
diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/imap-search-args.c
--- a/src/imap/imap-search-args.c	Fri Sep 30 18:53:09 2011 +0300
+++ b/src/imap/imap-search-args.c	Fri Sep 30 19:02:31 2011 +0300
@@ -117,6 +117,7 @@
 	    !msgset_is_valid(&args->args->value.seqset,
 			     cmd->client->messages_count)) {
 		*error_r = "Invalid messageset";
+		mail_search_args_unref(&args);
 		return -1;
 	}
 	*args_r = args;
@@ -135,6 +136,7 @@
 	p_array_init(&args->args->value.seqset, args->pool, 16);
 	if (imap_seq_set_parse(uidset, &args->args->value.seqset) < 0) {
 		*error_r = "Invalid uidset";
+		mail_search_args_unref(&args);
 		return -1;
 	}
 


More information about the dovecot-cvs mailing list