aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-02-12 16:41:59 -0600
committerRob Landley <rob@landley.net>2015-02-12 16:41:59 -0600
commit67d9ea5a81c8083875ac7420d7e6a62766b48b6f (patch)
tree6e0fc10e2ef16fef82292844a4cbefe092f52766 /toys/lsb
parentb2bb6e65f3461d1dfdcd3614c3c63f7a1453840b (diff)
downloadtoybox-67d9ea5a81c8083875ac7420d7e6a62766b48b6f.tar.gz
Fix bug introduced by last commit (print template instead of toybuf).
Also, xstrdup() the unmodified template because changing the environment string could make the changed version show up in "ps".
Diffstat (limited to 'toys/lsb')
-rw-r--r--toys/lsb/mktemp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c
index f756ffe6..cc426656 100644
--- a/toys/lsb/mktemp.c
+++ b/toys/lsb/mktemp.c
@@ -40,11 +40,14 @@ void mktemp_main(void)
if (!TT.tmpdir) TT.tmpdir = getenv("TMPDIR");
if (!TT.tmpdir) TT.tmpdir = "/tmp";
- if (!strchr(template, '/')) template = xmprintf("%s/%s", TT.tmpdir, template);
+ template = strchr(template, '/') ? xstrdup(template)
+ : xmprintf("%s/%s", TT.tmpdir, template);
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);
- } else xputs(toybuf);
+ } else xputs(template);
+
+ if (CFG_TOYBOX_FREE) free(template);
}