mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
misc: Use a fixed buffer for getenv().
This commit is contained in:
@@ -215,7 +215,13 @@ char *ssh_get_user_home_dir(void) {
|
|||||||
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
|
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
szPath = getenv("HOME");
|
szPath = getenv("HOME");
|
||||||
return szPath ? strdup(szPath) : NULL;
|
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);
|
szPath = strdup(pwd.pw_dir);
|
||||||
|
|||||||
Reference in New Issue
Block a user