[patch, libstdc++, testsuite] Modify tests to use tmpnam()
Janis Johnson
janis187@us.ibm.com
Thu Mar 4 19:22:00 GMT 2010
On Wed, 2010-03-03 at 16:51 -0800, Ian Lance Taylor wrote:
> 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
For this test it's better to just use a file name that's unique for the
testsuite, which was not the case. Steve discovered that the warning
didn't affect test results, although it's not in prune.exp and I haven't
found out why it's ignored.
Janis
More information about the Gcc-patches
mailing list