tmpnam v mkstemp

Paul Eggert eggert@twinsun.com
Sat Nov 11 14:11:00 GMT 2000


> Date: Sat, 11 Nov 2000 13:47:20 -0800
> From: Geoff Keating <geoffk@geoffk.org>

> > xxxxxxxxx.so: the use of `tmpnam' is dangerous, better use `mkstemp'
> 
> It is a libc link-time warning....  use of tmpnam() can allow another user
> to overwrite files owned by the user running tmpnam() even if the
> other user cannot write to those files.

No, you can use `tmpnam' safely by opening the returned file name with
O_CREAT|O_EXCL.  This is similar to what `mkstemp' does internally.
I've seen applications that do this for portability reasons, as
`mkstemp' is not universally supported.

Does libc also warn about the use of functions like `strcpy' and
`gets' at link time?  They are security holes as well, if used
incorrectly.


More information about the Libc-alpha mailing list