diff options
author | Dug Song <dugsong@cvs.openbsd.org> | 2000-06-28 17:45:26 +0000 |
---|---|---|
committer | Dug Song <dugsong@cvs.openbsd.org> | 2000-06-28 17:45:26 +0000 |
commit | d778f0732491665c2fcfde91332f64c6fe9f2764 (patch) | |
tree | 16ae65cf0cac0449e10cab467650a9a6dd4070aa /lib | |
parent | f3990931c3d488ff08eb2e2f690107026a952d2f (diff) |
restrict editrc lookup to home directory, thanks kris@freebsd.org. ok deraadt@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libedit/el.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/libedit/el.c b/lib/libedit/el.c index 11710f6c84e..6a447f28a8b 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -1,4 +1,4 @@ -/* $OpenBSD: el.c,v 1.6 1997/06/29 23:40:48 millert Exp $ */ +/* $OpenBSD: el.c,v 1.7 2000/06/28 17:45:25 dugsong Exp $ */ /* $NetBSD: el.c,v 1.6 1997/04/24 18:54:16 christos Exp $ */ /*- @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; #else -static char rcsid[] = "$OpenBSD: el.c,v 1.6 1997/06/29 23:40:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: el.c,v 1.7 2000/06/28 17:45:25 dugsong Exp $"; #endif #endif /* not lint && not SCCSID */ @@ -296,14 +296,11 @@ el_source(el, fname) char *ptr, path[MAXPATHLEN]; if (fname == NULL) { - fname = &elpath[1]; - if ((fp = fopen(fname, "r")) == NULL) { - if (issetugid() != 0 || (ptr = getenv("HOME")) == NULL) - return -1; - fname = strncpy(path, ptr, sizeof(path) - 1); - path[sizeof(path) - 1] = '\0'; - (void)strncat(path, elpath, sizeof(path) - strlen(path)); - } + ptr = getenv("HOME"); + if (issetugid() != 0 || ptr == NULL || *ptr == '\0') + return -1; + (void) snprintf(path, sizeof(path), "%s%s", ptr, elpath); + fname = path; } if ((fp = fopen(fname, "r")) == NULL) |