dovecot-2.2: lib-storage: Fixed mail_search_args_simplify() with...

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 9 11:51:56 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/d397b0ad0ac4
changeset: 19498:d397b0ad0ac4
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Dec 09 13:51:35 2015 +0200
description:
lib-storage: Fixed mail_search_args_simplify() with empty args.
This fixes assert-crash in doveadm mailbox list.

diffstat:

 src/lib-storage/mail-search-args-simplify.c      |   5 ++++-
 src/lib-storage/test-mail-search-args-simplify.c |  14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diffs (50 lines):

diff -r 1d2999cfe0a4 -r d397b0ad0ac4 src/lib-storage/mail-search-args-simplify.c
--- a/src/lib-storage/mail-search-args-simplify.c	Wed Dec 09 13:02:46 2015 +0200
+++ b/src/lib-storage/mail-search-args-simplify.c	Wed Dec 09 13:51:35 2015 +0200
@@ -344,6 +344,9 @@
 	unsigned int count, lowest_count = UINT_MAX;
 	bool ret = FALSE;
 
+	if (*argsp == NULL)
+		return FALSE;
+
 	child_subargs_type = and_arg ? SEARCH_OR : SEARCH_SUB;
 
 	/* find the arg which has the lowest number of child args */
@@ -399,7 +402,7 @@
 	struct mail_search_arg *new_arg, *child_arg, *common_args = NULL;
 	enum mail_search_arg_type child_subargs_type;
 
-	if ((*argsp)->next == NULL) {
+	if (*argsp == NULL || (*argsp)->next == NULL) {
 		/* single arg, nothing to extract */
 		return FALSE;
 	}
diff -r 1d2999cfe0a4 -r d397b0ad0ac4 src/lib-storage/test-mail-search-args-simplify.c
--- a/src/lib-storage/test-mail-search-args-simplify.c	Wed Dec 09 13:02:46 2015 +0200
+++ b/src/lib-storage/test-mail-search-args-simplify.c	Wed Dec 09 13:51:35 2015 +0200
@@ -202,10 +202,24 @@
 	test_end();
 }
 
+static void test_mail_search_args_simplify_empty_lists(void)
+{
+	struct mail_search_args *args;
+
+	test_begin("mail search args simplify empty args");
+
+	args = mail_search_build_init();
+	mail_search_args_simplify(args);
+	mail_search_args_unref(&args);
+
+	test_end();
+}
+
 int main(void)
 {
 	static void (*test_functions[])(void) = {
 		test_mail_search_args_simplify,
+		test_mail_search_args_simplify_empty_lists,
 		NULL
 	};
 


More information about the dovecot-cvs mailing list