mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 8d3fa82d8246a08d2c7899963ad7cf61b7a4563c
parent 0c381fa2cb5d45f550817a78a00eb993bbe7005f
Author: Christian Neukirchen <chneukirchen@gmail.com>
Date:   Thu,  1 Sep 2016 20:56:54 +0200

seq: blaze822_home_file: guard missing entry in /etc/passwd or empty $HOME

Diffstat:
seq.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/seq.c b/seq.c @@ -24,8 +24,15 @@ blaze822_home_file(char *basename) if (!homedir) homedir = getenv("HOME"); + if (homedir && !*homedir) + homedir = 0; + if (!homedir) { + struct passwd *pw = getpwuid(getuid()); + if (pw) + homedir = pw->pw_dir; + } if (!homedir) - homedir = getpwuid(getuid())->pw_dir; + return "/dev/null/homeless"; snprintf(path, sizeof path, "%s/%s", homedir, basename);