[patch] use mkstemp instead of mktemp.
Ian Lance Taylor
ian@airs.com
Wed Jul 2 02:38:00 GMT 2003
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
More information about the Binutils
mailing list