This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [patch] use mkstemp instead of mktemp.
- From: Ian Lance Taylor <ian at airs dot com>
- To: Muthukumar Ratty <muthu at iqmail dot net>
- Cc: <binutils at sources dot redhat dot com>
- Date: 01 Jul 2003 19:37:51 -0700
- Subject: Re: [patch] use mkstemp instead of mktemp.
- References: <Pine.LNX.4.33.0307011858280.17775-100000@Muruga.localdomain>
Muthukumar Ratty <muthu@iqmail.net> writes:
> I was compiling the binutils from cvs and got the following warning ...
>
> /backup/bleed/BINUTILS/src/binutils/bucomm.c:441: the use of `mktemp' is
> dangerous, better use `mkstemp'
>
> Let me know if the following is ok...
You can't just mechanically replace mktemp() with mkstemp(). They
have different return values. mkstemp() returns the newly opened
file. Not using that return value is an error. So the code needs to
be rewritten. But you can't rewrite it trivially; some calls to
make_tempname() use the result to create a directory, and that can't
be done using mkstemp().
Also, mkstemp() is not available on all systems, so binutils code
shouldn't call it unless a replacement version is put into libiberty.
libiberty already has mkstemps(), which is a minor extension of
mkstemp(); for the binutils, it would probably be better to use that
rather than mkstemp().
Ian