2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Make arg splitting in visudo and sudoedit consistent.

This commit is contained in:
Todd C. Miller
2004-11-19 17:55:14 +00:00
parent 07139128f7
commit 6a78b91949
2 changed files with 15 additions and 11 deletions

View File

@@ -68,7 +68,7 @@ int sudo_edit(argc, argv)
const char *tmpdir;
char **nargv, **ap, *editor, *cp;
char buf[BUFSIZ];
int error, i, ac, ofd, tfd, nargc, rval, tmplen;
int error, i, ac, ofd, tfd, nargc, rval, tmplen, wasblank;
sigaction_t sa;
struct stat sb;
struct timespec ts1, ts2;
@@ -197,9 +197,13 @@ int sudo_edit(argc, argv)
* line args so look for those and alloc space for them too.
*/
nargc = argc;
for (cp = editor + 1; *cp != '\0'; cp++) {
if (isblank((unsigned char)cp[0]) && !isblank((unsigned char)cp[-1]))
for (wasblank = FALSE, cp = editor; *cp != '\0'; cp++) {
if (isblank((unsigned char) *cp))
wasblank = TRUE;
else if (wasblank) {
wasblank = FALSE;
nargc++;
}
}
nargv = (char **) emalloc2(nargc + 1, sizeof(char *));
ac = 0;