This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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, libstdc++, testsuite] Modify tests to use tmpnam()


Steve Ellcey <sje@cup.hp.com> writes:

> On Wed, 2010-03-03 at 14:57 -0800, Janis Johnson wrote:
>
>> I had forgotten that GNU ld warns about use of tmpnam:
>> 
>>    warning: the use of `tmpnam' is dangerous, better use `mkstemp'
>> 
>> It would be messy for the tests to turn off that warning since GNU ld
>> isn't the only linker used with GCC.  Other tests that use tmpnam are
>> compile-only and do not link.
>> 
>> Janis
>
> Is this warning triggered by some flag?  I ran the tests on Linux
> systems as well as HP-UX ones and I didn't get any failures.  I also
> don't see warnings in my log file.  The linux tests were done with the
> ToT GNU linker.

The warning is issued by GNU ld and gold because glibc has a
.gnu.warning.tmpnam section.  The contents of the section are the
above text.  In other words, the warning is from glibc.

In the context of the libstdc++ testsuite, the warning could be pruned
out by libstdc++-v3/testsuite/lib/prune.exp.

tmpnam is insecure in the sense that some other process can interpose
a file between the time that tmpnam is called and the time that the
file is created.  This problem is typically easily avoided by opening
the file using the O_EXCL flag.

Ian


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