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