aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/misc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/misc.c b/src/misc.c
index 14ca6162..64d9e0c2 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -214,8 +214,14 @@ char *ssh_get_user_home_dir(void) {
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
if (rc != 0) {
- szPath=getenv("HOME");
- return szPath ? strdup(szPath) : NULL;
+ szPath = getenv("HOME");
+ if (szPath == NULL) {
+ return NULL;
+ }
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), "%s", getenv("HOME"));
+
+ return strdup(buf);
}
szPath = strdup(pwd.pw_dir);