Mercurial > dovecot > core-2.2
changeset 19917:1ef6401c749d
lib-index: After MAIL_INDEX_OPEN_FLAG_SAVEONLY access cache's read_buf wasn't always reset.
This could have caused at least errors like:
Corrupted index cache file .../dovecot.index.cache: File too small
I'm not sure if it might have also returned stale data sometimes.
Easy way to reproduce this bug was:
imaptest copy=100 copybox=Trash &
imaptest box=Trash append=0
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 03 Mar 2016 00:15:30 +0200 |
parents | 92ebcea64322 |
children | e7fb4e09d051 |
files | src/lib-index/mail-cache.c |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache.c Tue Mar 01 22:11:05 2016 +0200 +++ b/src/lib-index/mail-cache.c Thu Mar 03 00:15:30 2016 +0200 @@ -60,6 +60,8 @@ if (cache->file_cache != NULL) file_cache_set_fd(cache->file_cache, -1); + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); cache->mmap_base = NULL; cache->hdr = NULL; @@ -465,6 +467,8 @@ /* map the whole file */ cache->hdr = NULL; cache->mmap_length = 0; + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); cache->mmap_base = mmap_ro_file(cache->fd, &cache->mmap_length); if (cache->mmap_base == MAP_FAILED) {