From 627ce4ea34f180745003f50c540a17cbfc5a22ba Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 20 Jul 2017 20:18:07 +0200 Subject: [PATCH] Fix segfault related to getting the uvar pipe path This tried setting $USER (again), but did it wrong. Fixes #4229 TO THE MAXXX. --- src/env_universal_common.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index b813ffc77..c340e5961 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -140,14 +140,11 @@ static wcstring get_runtime_path() { result = str2wcstring(dir); } else { const char *uname = getenv("USER"); - if (uname == NULL) { - struct passwd userinfo; - struct passwd *result; - char buf[8192]; - int retval = getpwuid_r(getuid(), &userinfo, buf, sizeof(buf), &result); - if (!retval && result) uname = userinfo.pw_name; + // $USER should already have been set (in setup_path()). + // If it still isn't, there's something wrong. + if (!uname) { + return result; } - // /tmp/fish.user std::string tmpdir = "/tmp/fish."; tmpdir.append(uname);