]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Human search parser now fails if given mailbox name isn't valid UTF8.
authorTimo Sirainen <tss@iki.fi>
Fri, 28 May 2010 11:31:05 +0000 (12:31 +0100)
committerTimo Sirainen <tss@iki.fi>
Fri, 28 May 2010 11:31:05 +0000 (12:31 +0100)
--HG--
branch : HEAD

src/lib-storage/mail-search-register-human.c

index 513ee5d90e6f87b235cbc8fe0bf0ae16a319f3bf..2b614b0af8568c03e95001223e219a28b3e08076 100644 (file)
@@ -135,17 +135,24 @@ static struct mail_search_arg *
 human_search_mailbox(struct mail_search_build_context *ctx)
 {
        struct mail_search_arg *sarg;
+       const char *value;
 
        sarg = mail_search_build_str(ctx, SEARCH_MAILBOX_GLOB);
+       value = sarg->value.str;
+
        T_BEGIN {
                string_t *str = t_str_new(128);
 
-               if (imap_utf8_to_utf7(sarg->value.str, str) < 0) {
-                       str_truncate(str, 0);
-                       str_append(str, sarg->value.str);
-               }
-               sarg->value.str = p_strdup(ctx->pool, str_c(str));
+               if (imap_utf8_to_utf7(value, str) < 0)
+                       sarg->value.str = NULL;
+               else
+                       sarg->value.str = p_strdup(ctx->pool, str_c(str));
        } T_END;
+       if (sarg->value.str == NULL) {
+               ctx->_error = p_strconcat(ctx->pool,
+                       "Mailbox name not valid UTF-8: ", value, NULL);
+               return NULL;
+       }
        return sarg;
 }