diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-05-29 09:23:05 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-05-29 09:23:05 +0200 |
commit | 697af69971f6f513d481110a22ce92bdfc2b86fa (patch) | |
tree | fa0d8699bed6f0b6040a11c8877eb3e2cf39a8c2 | |
parent | 2ed2900c094185ad3530cc63ea4d1d64f79cfa40 (diff) | |
download | gnutls-697af69971f6f513d481110a22ce92bdfc2b86fa.tar.gz |
check the return code of getpwuid_r()
Reported by Viktor Dukhovni.
-rw-r--r-- | lib/system.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/system.c b/lib/system.c index 230144fd8b..aea0ed2763 100644 --- a/lib/system.c +++ b/lib/system.c @@ -337,10 +337,11 @@ int _gnutls_find_config_path(char *path, size_t max_size) if (home_dir == NULL || home_dir[0] == '\0') { struct passwd *pwd; struct passwd _pwd; + int ret; char buf[1024]; - getpwuid_r(getuid(), &_pwd, buf, sizeof(buf), &pwd); - if (pwd != NULL) { + ret = getpwuid_r(getuid(), &_pwd, buf, sizeof(buf), &pwd); + if (ret == 0 && pwd != NULL) { snprintf(tmp_home_dir, sizeof(tmp_home_dir), "%s", pwd->pw_dir); } else { |