From 4d1c36051ec286018602123c449cc0b024e93c45 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 22 May 2000 05:55:22 +0000 Subject: [PATCH] Do not read editrc file from '.'. This can be as unsafe as having . first in root's path. While I'm here: o Add $FreeBSD$ o Get errno from , but extern int errno. Submitted by: Tim Vanderhoek --- lib/libedit/editline.3 | 2 -- lib/libedit/el.c | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/libedit/editline.3 b/lib/libedit/editline.3 index 7528f5fa86f2..3dda60dcce9d 100644 --- a/lib/libedit/editline.3 +++ b/lib/libedit/editline.3 @@ -381,8 +381,6 @@ If is .Dv NULL , try -.Pa $PWD/.editrc -then .Pa $HOME/.editrc . Refer to .Xr editrc 5 diff --git a/lib/libedit/el.c b/lib/libedit/el.c index 87f6813d455d..3ab5d834b84f 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -34,9 +34,13 @@ * SUCH DAMAGE. */ -#if !defined(lint) && !defined(SCCSID) +#if !defined(lint) +#if 0 static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; -#endif /* not lint && not SCCSID */ +#endif +static const char rcsid[] = + "$FreeBSD$" +#endif /* not lint */ /* * el.c: EditLine interface functions @@ -45,6 +49,7 @@ static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; #include #include +#include #include #include #if __STDC__ @@ -80,7 +85,6 @@ el_init(prog, fin, fout) if (issetugid() == 0 && (tty = getenv("DEBUGTTY")) != NULL) { el->el_errfile = fopen(tty, "w"); if (el->el_errfile == NULL) { - extern errno; (void) fprintf(stderr, "Cannot open %s (%s).\n", tty, strerror(errno)); return NULL; @@ -290,13 +294,10 @@ 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; - (void)snprintf(path, sizeof(path), "%s%s", ptr, elpath); - fname = path; - } + if (issetugid() != 0 || (ptr = getenv("HOME")) == NULL) + return -1; + (void) snprintf(path, sizeof(path), "%s%s", ptr, elpath); + fname = path; } if ((fp = fopen(fname, "r")) == NULL)