diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-10-08 22:38:20 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-10-12 14:45:54 +0200 |
commit | e04dc45f2043e8bf0a837eda84a909fa45cadf87 (patch) | |
tree | e0d2e49e9e3a7ea65342db2fb67c689b1679c37e | |
parent | de34a6489543e387bff8ef4fd615cbf069c57e93 (diff) | |
download | libssh-e04dc45f2043e8bf0a837eda84a909fa45cadf87.tar.gz libssh-e04dc45f2043e8bf0a837eda84a909fa45cadf87.tar.xz libssh-e04dc45f2043e8bf0a837eda84a909fa45cadf87.zip |
misc: Use a fixed buffer for getenv().
-rw-r--r-- | src/misc.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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); |