Mercurial > hg > toybox
changeset 1693:1e0af8b8c8ec draft
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".
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 12 Feb 2015 16:41:59 -0600 |
parents | ed94226a879e |
children | a5901bfefda5 |
files | toys/lsb/mktemp.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/lsb/mktemp.c Wed Feb 11 17:10:28 2015 -0600 +++ b/toys/lsb/mktemp.c Thu Feb 12 16:41:59 2015 -0600 @@ -40,11 +40,14 @@ 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); }