]> granicus.if.org Git - sudo/commitdiff
On Digital UNIX _PATH_VAR_TMP doesn't end with a trailing slash so
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 16 Nov 2004 20:54:37 +0000 (20:54 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 16 Nov 2004 20:54:37 +0000 (20:54 +0000)
chop off any trailing slashes we see and add an explicit one.

sudo_edit.c

index d8d136e49d64f4aac8f6977e03b34eceb78c201b..3d8d94089d3d2b1f38dc389a0bc305da971a294a 100644 (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);