diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2020-10-01 04:25:54 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2020-10-01 04:25:54 +0000 |
commit | b4ed613595432ece6802d09bfabad18e09aa26f3 (patch) | |
tree | bd2db6b09b756624c1b2babdd12ea05a9dffcdaf /common/util.c | |
parent | 7cef6c685d23e4dcdf3f64b0b2ea92151e652db6 (diff) |
Notes
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/util.c b/common/util.c index 1e87c6293550..8046ce373016 100644 --- a/common/util.c +++ b/common/util.c @@ -111,8 +111,9 @@ join(char *path1, char *path2) if (path1[0] == '\0' || path2[0] == '/') return strdup(path2); - (void)asprintf(&p, path1[strlen(path1)-1] == '/' ? - "%s%s" : "%s/%s", path1, path2); + if (asprintf(&p, path1[strlen(path1)-1] == '/' ? + "%s%s" : "%s/%s", path1, path2) == -1) + return NULL; return p; } @@ -140,8 +141,13 @@ expanduser(char *str) continue; if (t == p) { /* ~ */ +#ifdef __GLIBC__ + extern char *secure_getenv(const char *); + if ((h = secure_getenv("HOME")) == NULL) { +#else if (issetugid() != 0 || (h = getenv("HOME")) == NULL) { +#endif if (((h = getlogin()) != NULL && (pwd = getpwnam(h)) != NULL) || (pwd = getpwuid(getuid())) != NULL) |