[Bug libc/13983] __libc_message() shouldn't blindly write to STDERR_FILENO

nenolod at dereferenced dot org sourceware-bugzilla@sourceware.org
Mon Apr 16 08:34:00 GMT 2012


http://sourceware.org/bugzilla/show_bug.cgi?id=13983

--- Comment #9 from William Pitcock <nenolod at dereferenced dot org> 2012-04-16 08:33:46 UTC ---
(In reply to comment #8)
> I'm not sure anymore whether this is worth fixing.
> 
> (In reply to comment #7)
> > This is fine too, but glibc should make sure stderr really is stderr.
> 
> Ok, but how should we do that?

At libio/iofclose.c:85, there is:

  if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
    {
      fp->_IO_file_flags = 0;
      free(fp);
    }

This means we can always use fwrite on _IO_stdin, _IO_stdout, _IO_stderr, as
they will always stay around.  So, we can just use fwrite() with static
buffers, as they will have fp->_fileno = -1, which will silently fail.  Or we
can just use _IO_stderr->_fileno instead of STDERR_FILENO define.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the Glibc-bugs mailing list