changeset 1692:ed94226a879e

Only apply mktemp directory to targets that aren't already paths.
author Rob Landley <rob@landley.net>
date Wed, 11 Feb 2015 17:10:28 -0600
parents 9b1cbc13dfdc
children 1e0af8b8c8ec
files toys/lsb/mktemp.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/toys/lsb/mktemp.c	Tue Feb 10 22:51:23 2015 -0600
+++ b/toys/lsb/mktemp.c	Wed Feb 11 17:10:28 2015 -0600
@@ -40,9 +40,9 @@
   if (!TT.tmpdir) TT.tmpdir = getenv("TMPDIR");
   if (!TT.tmpdir) TT.tmpdir = "/tmp";
 
-  snprintf(toybuf, sizeof(toybuf), "%s/%s", TT.tmpdir, template);
+  if (!strchr(template, '/')) template = xmprintf("%s/%s", TT.tmpdir, template);
 
-  if (d_flag ? !mkdtemp(toybuf) : mkstemp(toybuf) == -1) {
+  if (d_flag ? !mkdtemp(template) : mkstemp(template) == -1) {
     if (toys.optflags & FLAG_q) toys.exitval = 1;
     else perror_exit("Failed to create %s %s/%s",
                      d_flag ? "directory" : "file", TT.tmpdir, template);