[PATCH v2 1/2] mktemp: avoid removed mktemp()
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Tue Apr 8 13:11:33 UTC 2014
mktemp() was removed from POSIX.1-2008
function old new delta
mktemp_main 214 223 +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0) Total: 9 bytes
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
debianutils/mktemp.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index 983d7a2..39d4345 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -92,16 +92,16 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
if (opts & (OPT_t|OPT_p))
chp = concat_path_file(path, chp);
- if (opts & OPT_u) {
- chp = mktemp(chp);
- if (chp[0] == '\0')
- goto error;
- } else if (opts & OPT_d) {
+ if (opts & OPT_d) {
if (mkdtemp(chp) == NULL)
goto error;
+ if (opts & OPT_u)
+ rmdir(chp);
} else {
if (mkstemp(chp) < 0)
goto error;
+ if (opts & OPT_u)
+ unlink(chp);
}
puts(chp);
return EXIT_SUCCESS;
--
1.9.1
More information about the busybox
mailing list