This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] use mkstemp instead of mktemp.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]