From: Todd C. Miller Date: Tue, 16 Nov 2004 20:54:37 +0000 (+0000) Subject: On Digital UNIX _PATH_VAR_TMP doesn't end with a trailing slash so X-Git-Tag: SUDO_1_7_0~817 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=900db20f7a0bfcfe3ee9641661628e484bce1cbd;p=sudo On Digital UNIX _PATH_VAR_TMP doesn't end with a trailing slash so chop off any trailing slashes we see and add an explicit one. --- diff --git a/sudo_edit.c b/sudo_edit.c index d8d136e49..3d8d94089 100644 --- a/sudo_edit.c +++ b/sudo_edit.c @@ -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; + int error, i, ac, ofd, tfd, nargc, rval, tmplen; sigaction_t sa; struct stat sb; struct timespec ts1, ts2; @@ -90,6 +90,9 @@ int sudo_edit(argc, argv) #endif else tmpdir = _PATH_TMP; + tmplen = strlen(tmpdir); + while (tmpdir[tmplen - 1] == '/') + tmplen--; /* * For each file specified by the user, make a temporary version @@ -134,7 +137,7 @@ int sudo_edit(argc, argv) cp++; else cp = tf[i].ofile; - easprintf(&tf[i].tfile, "%s%s.XXXXXXXX", tmpdir, cp); + easprintf(&tf[i].tfile, "%.*s/%s.XXXXXXXX", tmplen, tmpdir, cp); set_perms(PERM_USER); tfd = mkstemp(tf[i].tfile); set_perms(PERM_ROOT);