From: Timo Sirainen Date: Thu, 4 Aug 2011 16:57:02 +0000 (+0300) Subject: mail_index_get_keywords() / status.keywords weren't actually guaranteed to be NULL... X-Git-Tag: 2.1.alpha1~169 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5c53272acbe1517440aa9c277133babc887ee84;p=thirdparty%2Fdovecot%2Fcore.git mail_index_get_keywords() / status.keywords weren't actually guaranteed to be NULL terminated This could have caused crashes or garbage keywords be presented to clients in some situations. --- diff --git a/src/lib-index/mail-index.c b/src/lib-index/mail-index.c index bd0559e046..25200654b8 100644 --- a/src/lib-index/mail-index.c +++ b/src/lib-index/mail-index.c @@ -265,6 +265,10 @@ void mail_index_keyword_lookup_or_create(struct mail_index *index, hash_table_insert(index->keywords_hash, keyword_dup, POINTER_CAST(*idx_r)); array_append(&index->keywords, &keyword, 1); + + /* keep the array NULL-terminated, but the NULL itself invisible */ + (void)array_append_space(&index->keywords); + array_delete(&index->keywords, array_count(&index->keywords)-1, 1); } const ARRAY_TYPE(keywords) *mail_index_get_keywords(struct mail_index *index)