diff options
author | kris <kris@FreeBSD.org> | 2001-05-06 03:07:12 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2001-05-06 03:07:12 +0000 |
commit | ca9754c62774b32d7517180537892b8368b06456 (patch) | |
tree | 3e04a97826e97fe6589530618355cfa90a3992bb /gnu/usr.bin/rcs/lib/rcsfnms.c | |
parent | 08e03c867950bb514bac8b48cb92a19593e550ff (diff) | |
download | FreeBSD-src-ca9754c62774b32d7517180537892b8368b06456.zip FreeBSD-src-ca9754c62774b32d7517180537892b8368b06456.tar.gz |
Create temporary files securely using mkstemp() instead of mktemp()
Reviewed by: mikeh, audit@
MFC after: 1 week
Diffstat (limited to 'gnu/usr.bin/rcs/lib/rcsfnms.c')
-rw-r--r-- | gnu/usr.bin/rcs/lib/rcsfnms.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gnu/usr.bin/rcs/lib/rcsfnms.c b/gnu/usr.bin/rcs/lib/rcsfnms.c index 7d833bb..00caec5 100644 --- a/gnu/usr.bin/rcs/lib/rcsfnms.c +++ b/gnu/usr.bin/rcs/lib/rcsfnms.c @@ -284,6 +284,9 @@ maketemp(n) { char *p; char const *t = tpnames[n]; +# if has_mktemp + int fd; +# endif if (t) return t; @@ -295,10 +298,12 @@ maketemp(n) size_t tplen = dir_useful_len(tp); p = testalloc(tplen + 10); VOID sprintf(p, "%.*s%cT%cXXXXXX", (int)tplen, tp, SLASH, '0'+n); - if (!mktemp(p) || !*p) + fd = mkstemp(p); + if (fd < 0 || !*p) faterror("can't make temporary pathname `%.*s%cT%cXXXXXX'", (int)tplen, tp, SLASH, '0'+n ); + close(fd); # else static char tpnamebuf[TEMPNAMES][L_tmpnam]; p = tpnamebuf[n]; |