This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, libstdc++, testsuite] Modify tests to use tmpnam()
On Thu, 2010-03-04 at 00:00 +0100, Paolo Carlini wrote:
> Hi,
> > I am not sure what kind of comment you want. Maybe something like:
> > // Use tmpnam to create a unique name for the FIFO.
> >
> I had in mind some kind of reminder, like a fixme to use it in more
> places, consistently, but...
> > Hm, I just happened to look at the linux man page for tmpnam (as opposed
> > to the HPUX one) and noticed this:
> >
> > | BUGS
> > | Never use this function. Use mkstemp(3) or tmpfile(3) instead.
> >
> > But I don't think either of those routines can create a FIFO like we are
> > doing in these tests so this seems like a bogus comment in the man page.
> >
> ... I don' think it's bugus. I googled a bit and it seems a security
> hazard. I'm a bit worried, even if probably it doesn't matter much for a
> test. As I said above, we are looking for something solid, to be used
> also elsewhere in the testsuite, in the future.
>
> Paolo.
Steve, using tmpnam in this case is not a good idea and I should have
looked into it more before replying. There are lots of libstdc++ tests
that create temporary files with specific names, including several
called tmp_fifo*, and apparently those are working for you. The same
names are often used for multiple tests, and in this case tmp_fifo4 is
also used in the corresponding char test. If you look into the failure
some more and can't figure out what's going on, try changing the name
to tmp_fifo4w to make it unique among the tests. I remember having
issues in the ancient past with deleting files on NFS-mounted systems
and then needing to wait a bit before creating new ones of the same
name.
Janis