# HG changeset patch # User Timo Sirainen # Date 1189835757 -10800 # Node ID 06818dd6a95289d98e31f9a4f540a987ab330746 # Parent f33ea6ff46ea8c705f3db6d243d4235ec0a76d37 Make sure extensions updates don't modify keywords. diff -r f33ea6ff46ea -r 06818dd6a952 src/lib-index/mail-index-sync-ext.c --- a/src/lib-index/mail-index-sync-ext.c Sat Sep 15 08:54:43 2007 +0300 +++ b/src/lib-index/mail-index-sync-ext.c Sat Sep 15 08:55:57 2007 +0300 @@ -391,11 +391,23 @@ if (!mail_index_map_lookup_ext(map, name, &ext_map_idx)) ext_map_idx = (uint32_t)-1; } + ext = ext_map_idx == (uint32_t)-1 ? NULL : + array_idx(&map->extensions, ext_map_idx); + if (ext != NULL) + name = ext->name; + + if (!ctx->internal_update && strcmp(name, "keywords") == 0) { + /* Keyword extension is handled internally by the keyword + code. Any attempt to modify them directly could cause + assert-crashes later, so prevent them immediately. */ + mail_index_sync_set_corrupted(ctx, + "Extension introduction for keywords"); + t_pop(); + return -1; + } if (ext_map_idx != (uint32_t)-1) { /* exists already */ - ext = array_idx(&map->extensions, ext_map_idx); - if (u->reset_id == ext->reset_id) { /* check if we need to resize anything */ sync_ext_resize(u, ext_map_idx, ctx); @@ -462,7 +474,8 @@ sync_ext_reorder(map, ext_map_idx, 0); ctx->cur_ext_ignore = FALSE; - ctx->cur_ext_map_idx = ext_map_idx; + ctx->cur_ext_map_idx = ctx->internal_update ? + (uint32_t)-1 : ext_map_idx; return 1; } diff -r f33ea6ff46ea -r 06818dd6a952 src/lib-index/mail-index-sync-keywords.c --- a/src/lib-index/mail-index-sync-keywords.c Sat Sep 15 08:54:43 2007 +0300 +++ b/src/lib-index/mail-index-sync-keywords.c Sat Sep 15 08:55:57 2007 +0300 @@ -101,15 +101,17 @@ buffer_append(ext_intro_buf, "keywords", u->name_size); } + ctx->internal_update = TRUE; if (mail_index_sync_ext_intro(ctx, u) < 0) i_panic("Keyword extension growing failed"); + ctx->internal_update = FALSE; } static void keywords_header_add(struct mail_index_sync_map_ctx *ctx, const char *keyword_name, unsigned int *keyword_idx_r) { - struct mail_index_map *map = ctx->view->map; + struct mail_index_map *map; const struct mail_index_ext *ext = NULL; struct mail_index_keyword_header *kw_hdr; struct mail_index_keyword_header_rec kw_rec; diff -r f33ea6ff46ea -r 06818dd6a952 src/lib-index/mail-index-sync-private.h --- a/src/lib-index/mail-index-sync-private.h Sat Sep 15 08:54:43 2007 +0300 +++ b/src/lib-index/mail-index-sync-private.h Sat Sep 15 08:55:57 2007 +0300 @@ -39,6 +39,7 @@ unsigned int expunge_handlers_set:1; unsigned int expunge_handlers_used:1; unsigned int cur_ext_ignore:1; + unsigned int internal_update:1; /* used by keywords for ext_intro */ unsigned int errors:1; };