summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-05-29 09:23:05 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-05-29 09:23:05 +0200
commit697af69971f6f513d481110a22ce92bdfc2b86fa (patch)
treefa0d8699bed6f0b6040a11c8877eb3e2cf39a8c2
parent2ed2900c094185ad3530cc63ea4d1d64f79cfa40 (diff)
downloadgnutls-697af69971f6f513d481110a22ce92bdfc2b86fa.tar.gz
check the return code of getpwuid_r()
Reported by Viktor Dukhovni.
-rw-r--r--lib/system.c5
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 {