]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix potential crash when writing to unusable dovecot.index.cache
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 17 Feb 2020 13:39:14 +0000 (15:39 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 17 Feb 2020 13:41:09 +0000 (15:41 +0200)
Broken by a4671d9c5744d728e030370a39df914cebefbefe

src/lib-index/mail-cache-transaction.c

index 43779ba62defc948fdbc0849470fa688d630c2a4..22b148050f93b52e3e335554798732d6aab1fe2f 100644 (file)
@@ -264,8 +264,9 @@ static int mail_cache_transaction_lock(struct mail_cache_transaction_ctx *ctx)
            cache->last_stat_size + ctx->cache_data->used >= cache_max_size) {
                /* Looks like cache file is becoming too large. Try to compress
                   it to free up some space. */
-               if (cache->hdr->continued_record_count > 0 ||
-                   cache->hdr->deleted_record_count > 0)
+               if (!MAIL_CACHE_IS_UNUSABLE(cache) &&
+                   (cache->hdr->continued_record_count > 0 ||
+                    cache->hdr->deleted_record_count > 0))
                        (void)mail_cache_transaction_compress(ctx);
        }