From c153de987df3a2989a72f200528a9ea6d1990a16 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Thu, 6 Jun 1996 12:10:02 +0000 Subject: [PATCH] system() $EDITOR safely --- src/lib/libutil/passwd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib/libutil/passwd.c b/src/lib/libutil/passwd.c index c473eca7..0d03133d 100644 --- a/src/lib/libutil/passwd.c +++ b/src/lib/libutil/passwd.c @@ -154,19 +154,21 @@ pw_edit(notsetuid, filename) filename = _PATH_MASTERPASSWD_LOCK; if (!(editor = getenv("EDITOR"))) editor = _PATH_VI; - if (p = strrchr(editor, '/')) - ++p; - else - p = editor; + + p = malloc(strlen(editor) + 1 + strlen(filename) + 1); + if (p == NULL) + return; + sprintf(p, "%s %s", editor, filename); if (!(editpid = vfork())) { if (notsetuid) { setgid(getgid()); setuid(getuid()); } - execlp(editor, p, filename, NULL); + system(p); _exit(1); } + free(p); for (;;) { editpid = waitpid(editpid, (int *)&pstat, WUNTRACED); if (editpid == -1)