summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/mktemp.c
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-03-14 12:14:08 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-03-14 12:14:08 +0000
commit71675a3908d8bf650dce62d174d33391dbaafd2d (patch)
tree903a4a5fdb18b53aadf8aea0e2b69fce78c623f0 /newlib/libc/stdio/mktemp.c
parentc7cf32ee27bdd157bd7308705a94e62382c5883c (diff)
downloadcygnal-71675a3908d8bf650dce62d174d33391dbaafd2d.tar.gz
cygnal-71675a3908d8bf650dce62d174d33391dbaafd2d.tar.bz2
cygnal-71675a3908d8bf650dce62d174d33391dbaafd2d.zip
* libc/include/stdio.h (_mkstemp_r, _mktemp_r): Move declarations
to stdlib.h. * libc/include/stdlib.h (mktemp, _mktemp_r): Warn when using. * libc/stdio/mktemp.c: Explain the security risk when using mktemp.
Diffstat (limited to 'newlib/libc/stdio/mktemp.c')
-rw-r--r--newlib/libc/stdio/mktemp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c
index e00228e15..c4347cd05 100644
--- a/newlib/libc/stdio/mktemp.c
+++ b/newlib/libc/stdio/mktemp.c
@@ -85,6 +85,13 @@ unless it could not generate an unused filename, or the pattern you
provided is not suitable for a filename; in that case, it returns
<<-1>>.
+NOTES
+Never use <<mktemp>>. The generated filenames are easy to guess and
+there's a race between the test if the file exists and the creation
+of the file. In combination this makes <<mktemp>> prone to attacks
+and using it is a security risk. Whenever possible use <<mkstemp>>
+instead. It doesn't suffer the race condition.
+
PORTABILITY
ANSI C does not require either <<mktemp>> or <<mkstemp>>; the System
V Interface Definition requires <<mktemp>> as of Issue 2.