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

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.
This commit is contained in:
Todd C. Miller
2004-11-16 20:54:37 +00:00
parent 0ed2557959
commit 900db20f7a

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;
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);