aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/misc.c b/src/misc.c
index 90b63330..782b7bc0 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -217,12 +217,12 @@ char *ssh_get_user_home_dir(void)
{
char *szPath = NULL;
struct passwd pwd;
- struct passwd *pwdbuf;
+ struct passwd *pwdbuf = NULL;
char buf[NSS_BUFLEN_PASSWD] = {0};
int rc;
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
- if (rc != 0) {
+ if (rc != 0 || pwdbuf == NULL ) {
szPath = getenv("HOME");
if (szPath == NULL) {
return NULL;
@@ -250,13 +250,13 @@ int ssh_file_readaccess_ok(const char *file)
char *ssh_get_local_username(void)
{
struct passwd pwd;
- struct passwd *pwdbuf;
+ struct passwd *pwdbuf = NULL;
char buf[NSS_BUFLEN_PASSWD];
char *name;
int rc;
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
- if (rc != 0) {
+ if (rc != 0 || pwdbuf == NULL) {
return NULL;
}