From 51e4b02aa1055ec5a9144c2c93eef4e5823a1804 Mon Sep 17 00:00:00 2001 From: jonb Date: Thu, 5 Dec 2002 22:54:45 +0000 Subject: [PATCH] Fix the way $EDITOR is started so the variable can have flags in addition to the name of the binary to run. --- usr.sbin/edquota/edquota.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 62f81b4ea98b..51eabfd66fe5 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1990, 1993\n\ #if 0 static char sccsid[] = "from: @(#)edquota.c 8.3 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: edquota.c,v 1.22 2002/12/04 21:01:13 bouyer Exp $"); +__RCSID("$NetBSD: edquota.c,v 1.23 2002/12/05 22:54:45 jonb Exp $"); #endif #endif /* not lint */ @@ -84,6 +84,8 @@ struct quotause { }; #define FOUND 0x01 +#define MAX_TMPSTR (100+MAXPATHLEN) + int main __P((int, char **)); void usage __P((void)); int getentry __P((char *, int)); @@ -416,6 +418,7 @@ editit(tmpfile) { long omask; int pid, stat; + char p[MAX_TMPSTR]; omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); top: @@ -440,7 +443,11 @@ editit(tmpfile) setuid(getuid()); if ((ed = getenv("EDITOR")) == (char *)0) ed = _PATH_VI; - execlp(ed, ed, tmpfile, 0); + if (strlen(ed) + strlen(tmpfile) + 2 >= MAX_TMPSTR) { + err (1, "%s", "editor or filename too long"); + } + snprintf (p, MAX_TMPSTR, "%s %s", ed, tmpfile); + execlp(_PATH_BSHELL, _PATH_BSHELL, "-c", p, NULL); err(1, "%s", ed); } waitpid(pid, &stat, 0);