From e81ce175464c5bb7a39d5548b82b5671dfb5e0d0 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 9 May 2019 19:27:18 +0300 Subject: [PATCH] lib-storage: Fix mail_user_home_mkdir() crash when user has no home directory This is used only by dsync when creating lock file. It wouldn't work without a home directory anyway. --- src/lib-storage/mail-user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c index fadc221211..42ec840b17 100644 --- a/src/lib-storage/mail-user.c +++ b/src/lib-storage/mail-user.c @@ -750,8 +750,10 @@ int mail_user_home_mkdir(struct mail_user *user) const char *home; int ret; - if (mail_user_get_home(user, &home) < 0) - return -1; + if ((ret = mail_user_get_home(user, &home)) <= 0) { + /* If user has no home directory, just return success. */ + return ret; + } /* Try to create the home directory by creating the root directory for a namespace that exists under the home. This way we end up in the -- 2.47.3