Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7054:4c6e9edfd4ce HEAD
Fixed crashes at error conditions.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 29 Dec 2007 06:13:35 +0200 |
parents | 622fa7cef9db |
children | 428884a4e297 |
files | src/lib-index/mail-cache-sync-update.c src/lib-index/mail-cache-transaction.c src/lib-index/mail-index-sync-update.c |
diffstat | 3 files changed, 19 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-sync-update.c Sat Dec 29 05:50:06 2007 +0200 +++ b/src/lib-index/mail-cache-sync-update.c Sat Dec 29 06:13:35 2007 +0200 @@ -45,7 +45,7 @@ int ret; if (ctx->locked) - return 1; + return MAIL_CACHE_IS_UNUSABLE(cache) ? 0 : 1; if (ctx->lock_failed) return 0; @@ -59,17 +59,17 @@ return 1; } -static int get_cache_file_seq(struct mail_index_view *view, +static bool get_cache_file_seq(struct mail_index_view *view, uint32_t *cache_file_seq_r) { const struct mail_index_ext *ext; ext = mail_index_view_get_ext(view, view->index->cache->ext_id); if (ext == NULL) - return 0; + return FALSE; *cache_file_seq_r = ext->reset_id; - return 1; + return TRUE; } int mail_cache_expunge_handler(struct mail_index_sync_map_ctx *sync_ctx,
--- a/src/lib-index/mail-cache-transaction.c Sat Dec 29 05:50:06 2007 +0200 +++ b/src/lib-index/mail-cache-transaction.c Sat Dec 29 06:13:35 2007 +0200 @@ -152,11 +152,12 @@ (void)mail_cache_open_and_verify(cache); return; } - if (MAIL_CACHE_IS_UNUSABLE(cache)) - return; /* see if we should try to reopen the cache file */ for (i = 0;; i++) { + if (MAIL_CACHE_IS_UNUSABLE(cache)) + return; + if (!mail_index_map_get_ext_idx(cache->index->map, cache->ext_id, &idx)) return;
--- a/src/lib-index/mail-index-sync-update.c Sat Dec 29 05:50:06 2007 +0200 +++ b/src/lib-index/mail-index-sync-update.c Sat Dec 29 06:13:35 2007 +0200 @@ -192,7 +192,7 @@ } } -static int +static void sync_expunge_call_handlers(struct mail_index_sync_map_ctx *ctx, uint32_t seq1, uint32_t seq2) { @@ -202,25 +202,27 @@ /* call expunge handlers only when syncing index file */ if (ctx->type != MAIL_INDEX_SYNC_HANDLER_FILE) - return 0; + return; if (!ctx->expunge_handlers_set) mail_index_sync_init_expunge_handlers(ctx); if (!array_is_created(&ctx->expunge_handlers)) - return 0; + return; eh = array_get(&ctx->expunge_handlers, &count); for (i = 0; i < count; i++, eh++) { for (; seq1 <= seq2; seq1++) { rec = MAIL_INDEX_MAP_IDX(ctx->view->map, seq1-1); - if (eh->handler(ctx, seq1, - PTR_OFFSET(rec, eh->record_offset), - eh->sync_context, eh->context) < 0) - return -1; + /* FIXME: does expunge handler's return value matter? + we probably shouldn't disallow expunges if the + handler returns failure.. should it be just changed + to return void? */ + (void)eh->handler(ctx, seq1, + PTR_OFFSET(rec, eh->record_offset), + eh->sync_context, eh->context); } } - return 0; } static int @@ -239,6 +241,8 @@ continue; } + sync_expunge_call_handlers(ctx, seq1, seq2); + map = mail_index_sync_get_atomic_map(ctx); for (seq = seq1; seq <= seq2; seq++) { rec = MAIL_INDEX_MAP_IDX(map, seq-1); @@ -247,9 +251,6 @@ FALSE); } - if (sync_expunge_call_handlers(ctx, seq1, seq2) < 0) - return -1; - /* @UNSAFE */ memmove(MAIL_INDEX_MAP_IDX(map, seq1-1), MAIL_INDEX_MAP_IDX(map, seq2),