dovecot-1.2: lib-storage: Don't crash when searching multiple ke...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Oct 5 00:26:24 EEST 2012
details: http://hg.dovecot.org/dovecot-1.2/rev/d6bd9acd97e7
changeset: 9657:d6bd9acd97e7
user: Timo Sirainen <tss at iki.fi>
date: Fri Oct 05 00:26:19 2012 +0300
description:
lib-storage: Don't crash when searching multiple keywords.
Fixed by simply removing the keyword merging code.
mail_search_args_simplify() is called before mail_search_args_init(), so the
keywords are still NULL and merging can't be done. Alternative fix would
have been to add string array to mail_search_arg.value containing the
keywords, but all of this is a pretty unnecessary optimization.
diffstat:
src/lib-storage/mail-search.c | 61 -------------------------------------------
1 files changed, 0 insertions(+), 61 deletions(-)
diffs (85 lines):
diff -r 6862d534e5b1 -r d6bd9acd97e7 src/lib-storage/mail-search.c
--- a/src/lib-storage/mail-search.c Tue Jul 17 16:20:20 2012 +0300
+++ b/src/lib-storage/mail-search.c Fri Oct 05 00:26:19 2012 +0300
@@ -510,46 +510,13 @@
return buffer_get_data(headers, NULL);
}
-static struct mail_keywords *
-mail_search_keywords_merge(struct mail_keywords **_kw1,
- struct mail_keywords **_kw2)
-{
- struct mail_keywords *kw1 = *_kw1, *kw2 = *_kw2;
- struct mail_keywords *new_kw;
-
- i_assert(kw1->index == kw2->index);
- T_BEGIN {
- ARRAY_TYPE(keyword_indexes) new_indexes;
- unsigned int i, j;
-
- t_array_init(&new_indexes, kw1->count + kw2->count + 1);
- array_append(&new_indexes, kw1->idx, kw1->count);
- for (i = 0; i < kw2->count; i++) {
- /* don't add duplicates */
- for (j = 0; j < kw1->count; j++) {
- if (kw1->idx[j] == kw2->idx[i])
- break;
- }
- if (j == kw1->count)
- array_append(&new_indexes, kw2->idx+i, 1);
- }
- new_kw = mail_index_keywords_create_from_indexes(kw1->index,
- &new_indexes);
- } T_END;
- mail_index_keywords_free(_kw1);
- mail_index_keywords_free(_kw2);
- return new_kw;
-}
-
static void
mail_search_args_simplify_sub(struct mail_search_arg *args, bool parent_and)
{
struct mail_search_arg *sub, *prev = NULL;
struct mail_search_arg *prev_flags_arg, *prev_not_flags_arg;
- struct mail_search_arg *prev_kw_arg, *prev_not_kw_arg;
prev_flags_arg = prev_not_flags_arg = NULL;
- prev_kw_arg = prev_not_kw_arg = NULL;
while (args != NULL) {
if (args->not && (args->type == SEARCH_SUB ||
args->type == SEARCH_OR)) {
@@ -608,34 +575,6 @@
}
}
- /* merge all keywords arguments */
- if (args->type == SEARCH_KEYWORDS && !args->not && parent_and) {
- if (prev_kw_arg == NULL)
- prev_kw_arg = args;
- else {
- prev_kw_arg->value.keywords =
- mail_search_keywords_merge(
- &prev_kw_arg->value.keywords,
- &args->value.keywords);
- prev->next = args->next;
- args = args->next;
- continue;
- }
- } else if (args->type == SEARCH_KEYWORDS && args->not &&
- !parent_and) {
- if (prev_not_kw_arg == NULL)
- prev_not_kw_arg = args;
- else {
- prev_not_kw_arg->value.keywords =
- mail_search_keywords_merge(
- &prev_not_kw_arg->value.keywords,
- &args->value.keywords);
- prev->next = args->next;
- args = args->next;
- continue;
- }
- }
-
prev = args;
args = args->next;
}
More information about the dovecot-cvs
mailing list