public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11538] New: invalid use of errno after calling ttyname_r
@ 2010-04-25 20:12 bruno at clisp dot org
  2010-04-25 20:15 ` [Bug libc/11538] " bruno at clisp dot org
  2010-05-03 17:01 ` drepper at redhat dot com
  0 siblings, 2 replies; 4+ messages in thread
From: bruno at clisp dot org @ 2010-04-25 20:12 UTC (permalink / raw)
  To: glibc-bugs

ttyname_r is specified in POSIX
<http://www.opengroup.org/onlinepubs/9699919799/functions/ttyname.html>.
The return value is specified like this:
"If successful, the ttyname_r() function shall return zero.
 Otherwise, an error number shall be returned to indicate the error."

This means, ttyname_r should return the error number. Whether it
additionally stores it in errno, is not specified. And indeed,
the two implementations in glibc/sysdeps/posix/ttyname_r.c and
glibc/sysdeps/unix/sysv/linux/ttyname_r.c can fail, returning
ENOTTY, without setting errno to ENOTTY. (Look at the end of the
function getttyname_r: If it cannot find the tty, it sets errno to
its previous value ('save') and returns ENOTTY. When all calls to
getttyname_r end like this, __ttyname_r returns ENOTTY without
assigning errno.)

Therefore, callers of ttyname_r should not use the value of errno
after the call failed, but instead use the return value from ttyname_r.

Find attached a fix.

-- 
           Summary: invalid use of errno after calling ttyname_r
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bruno at clisp dot org
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/11538] invalid use of errno after calling ttyname_r
  2010-04-25 20:12 [Bug libc/11538] New: invalid use of errno after calling ttyname_r bruno at clisp dot org
@ 2010-04-25 20:15 ` bruno at clisp dot org
  2010-05-03 17:01 ` drepper at redhat dot com
  1 sibling, 0 replies; 4+ messages in thread
From: bruno at clisp dot org @ 2010-04-25 20:15 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From bruno at clisp dot org  2010-04-25 20:15 -------
Created an attachment (id=4752)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4752&action=view)
proposed fix


-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/11538] invalid use of errno after calling ttyname_r
  2010-04-25 20:12 [Bug libc/11538] New: invalid use of errno after calling ttyname_r bruno at clisp dot org
  2010-04-25 20:15 ` [Bug libc/11538] " bruno at clisp dot org
@ 2010-05-03 17:01 ` drepper at redhat dot com
  1 sibling, 0 replies; 4+ messages in thread
From: drepper at redhat dot com @ 2010-05-03 17:01 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2010-05-03 17:00 -------
Already applied.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/11538] invalid use of errno after calling ttyname_r
       [not found] <bug-11538-131@http.sourceware.org/bugzilla/>
@ 2014-06-30  9:19 ` fweimer at redhat dot com
  0 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-30  9:19 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=11538

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-30  9:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-25 20:12 [Bug libc/11538] New: invalid use of errno after calling ttyname_r bruno at clisp dot org
2010-04-25 20:15 ` [Bug libc/11538] " bruno at clisp dot org
2010-05-03 17:01 ` drepper at redhat dot com
     [not found] <bug-11538-131@http.sourceware.org/bugzilla/>
2014-06-30  9:19 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).