2.3.11.3 mail_cache_open_or_create_path called with null path

Timo Sirainen timo at sirainen.com
Thu Aug 13 15:47:30 EEST 2020


On 13. Aug 2020, at 14.14, Stuart Henderson <stu at spacehopper.org> wrote:
> 
> Originally reported here -
> https://marc.info/?l=openbsd-ports&m=159731598419071&w=2
> 
> OpenBSD's printf functions have a (mostly annoying but occasionally
> useful) feature where they generate a syslog entry if printf %s format
> is called with a null pointer.
> 
> It is tripped in lmtp/lda deliveries with 2.3.11.3:
> 
> lmtp: vfprintf %s NULL in "Cache %s: "
> dovecot-lda: vfprintf %s NULL in "Cache %s: "

Thanks. This would fix it:

    lib-index: Fix cache event's log prefix for in-memory indexes
    
    It was either shown as "Cache (null): " or it could have crashed in some
    OSes.

diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c
index c7197cd4b8..9f4e58b075 100644
--- a/src/lib-index/mail-cache.c
+++ b/src/lib-index/mail-cache.c
@@ -569,8 +569,13 @@ mail_cache_open_or_create_path(struct mail_index *index, const char *path)
 
 	cache->event = event_create(index->event);
 	event_add_category(cache->event, &event_category_mail_cache);
-	event_set_append_log_prefix(cache->event,
-		t_strdup_printf("Cache %s: ", cache->filepath));
+	if (cache->filepath != NULL) {
+		event_set_append_log_prefix(cache->event,
+			t_strdup_printf("Cache %s: ", cache->filepath));
+	} else {
+		event_set_append_log_prefix(cache->event,
+					    "Cache (in-memory index): ");
+	}
 
 	cache->dotlock_settings.use_excl_lock =
 		(index->flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0;



More information about the dovecot mailing list