aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2020-10-01 04:25:54 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2020-10-01 04:25:54 +0000
commitb4ed613595432ece6802d09bfabad18e09aa26f3 (patch)
treebd2db6b09b756624c1b2babdd12ea05a9dffcdaf /common/util.c
parent7cef6c685d23e4dcdf3f64b0b2ea92151e652db6 (diff)
downloadsrc-vendor/nvi.tar.gz
src-vendor/nvi.zip
Import nvi 2.2.0-05ed8b9vendor/nvi/2.2.0-05ed8b9vendor/nvi
This snapshot just brings a bunch of fixes in particular a fix for vi -w PR: 241985 Reported by: fernape
Notes
Notes: svn path=/vendor/nvi/dist/; revision=366307 svn path=/vendor/nvi/2.2.0-05ed8b9/; revision=366308; tag=vendor/nvi/2.2.0-05ed8b9
Diffstat (limited to 'common/util.c')
-rw-r--r--common/util.c10
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)