aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb/mktemp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-12-30 20:54:19 -0600
committerRob Landley <rob@landley.net>2015-12-30 20:54:19 -0600
commit4ff9295f462c4f753902e6e520f645cad305aec6 (patch)
treeec5ab38e3217f5bec54040b47c71e04693a3c4ae /toys/lsb/mktemp.c
parent46ddb5520731aaf578de9d620f894395fb9d58b6 (diff)
downloadtoybox-4ff9295f462c4f753902e6e520f645cad305aec6.tar.gz
Don't let mktemp -q /path/to/file delete arbitrary files, and don't have
"mktemp -u > /dev/full" leave file around.
Diffstat (limited to 'toys/lsb/mktemp.c')
-rw-r--r--toys/lsb/mktemp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c
index f1f9d885..118daccf 100644
--- a/toys/lsb/mktemp.c
+++ b/toys/lsb/mktemp.c
@@ -48,8 +48,10 @@ void mktemp_main(void)
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(template);
- if (toys.optflags & FLAG_u) unlink(template);
+ } else {
+ if (toys.optflags & FLAG_u) unlink(template);
+ xputs(template);
+ }
if (CFG_TOYBOX_FREE) free(template);
}