public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY
       [not found] <bug-10932-131@http.sourceware.org/bugzilla/>
@ 2014-07-01  5:27 ` fweimer at redhat dot com
  0 siblings, 0 replies; 6+ messages in thread
From: fweimer at redhat dot com @ 2014-07-01  5:27 UTC (permalink / raw)
  To: glibc-bugs

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

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] 6+ messages in thread

* [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY
  2009-11-09 16:42 [Bug libc/10932] New: " yann at droneaud dot fr
                   ` (3 preceding siblings ...)
  2009-11-09 21:56 ` yann at droneaud dot fr
@ 2009-11-10 10:18 ` schwab at linux-m68k dot org
  4 siblings, 0 replies; 6+ messages in thread
From: schwab at linux-m68k dot org @ 2009-11-10 10:18 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From schwab at linux-m68k dot org  2009-11-10 10:18 -------
errno is only valid after a call returned EOF and ferror is true.

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


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

------- 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] 6+ messages in thread

* [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY
  2009-11-09 16:42 [Bug libc/10932] New: " yann at droneaud dot fr
                   ` (2 preceding siblings ...)
  2009-11-09 17:11 ` yann at droneaud dot fr
@ 2009-11-09 21:56 ` yann at droneaud dot fr
  2009-11-10 10:18 ` schwab at linux-m68k dot org
  4 siblings, 0 replies; 6+ messages in thread
From: yann at droneaud dot fr @ 2009-11-09 21:56 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From yann at droneaud dot fr  2009-11-09 21:56 -------
Created an attachment (id=4375)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4375&action=view)
Improved test case (use ferror() and feof())

Here is another version of the test case which use ferror() and feof() to
distinguish EOF roots (rationale:
<http://www.opengroup.org/onlinepubs/9699919799/functions/fgetc.html> )

Without fix:

  $ ./stdio-errno /dev/null
  fscanf() returned EOF
  feof() returned true
  >>> fscanf() failed: 25 Inappropriate ioctl for device
  fgetc() returned EOF
  feof() returned true
  >>> fgetc() failed: 25 Inappropriate ioctl for device

  $ ./stdio-errno /dev/zero
  fscanf() failed to parse anything
  fgetc() returned 0 (0x00000000)
  >>> fgetc() failed: 25 Inappropriate ioctl for device

With fix:

  $ ../scm/glibc-build/testrun.sh ./stdio-errno /dev/null
  fscanf() returned EOF
  feof() returned true
  fgetc() returned EOF
  feof() returned true

  $ ../scm/glibc-build/testrun.sh ./stdio-errno /dev/zero
  fscanf() failed to parse anything
  fgetc() returned 0 (0x00000000)


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
Attachment #4371 is|0                           |1
           obsolete|                            |


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

------- 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] 6+ messages in thread

* [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY
  2009-11-09 16:42 [Bug libc/10932] New: " yann at droneaud dot fr
  2009-11-09 17:00 ` [Bug libc/10932] " yann at droneaud dot fr
  2009-11-09 17:02 ` yann at droneaud dot fr
@ 2009-11-09 17:11 ` yann at droneaud dot fr
  2009-11-09 21:56 ` yann at droneaud dot fr
  2009-11-10 10:18 ` schwab at linux-m68k dot org
  4 siblings, 0 replies; 6+ messages in thread
From: yann at droneaud dot fr @ 2009-11-09 17:11 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From yann at droneaud dot fr  2009-11-09 17:11 -------
Created an attachment (id=4372)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4372&action=view)
Fix call to isatty() in libio

Here is a proposal fix for this problem.

With the patch, the test case returns:

  $ ./stdio-errno /dev/null
  fscanf() returned EOF
  fgetc() returned EOF

  $ ./stdio-errno /dev/zero
  fscanf() failed to parse anything
  fgetc() returned 0 (0x00000000)


-- 


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

------- 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] 6+ messages in thread

* [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY
  2009-11-09 16:42 [Bug libc/10932] New: " yann at droneaud dot fr
  2009-11-09 17:00 ` [Bug libc/10932] " yann at droneaud dot fr
@ 2009-11-09 17:02 ` yann at droneaud dot fr
  2009-11-09 17:11 ` yann at droneaud dot fr
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: yann at droneaud dot fr @ 2009-11-09 17:02 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From yann at droneaud dot fr  2009-11-09 17:01 -------
Note: the test case also failed on FreeBSD but don't failed on OpenSolaris.


-- 


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

------- 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] 6+ messages in thread

* [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY
  2009-11-09 16:42 [Bug libc/10932] New: " yann at droneaud dot fr
@ 2009-11-09 17:00 ` yann at droneaud dot fr
  2009-11-09 17:02 ` yann at droneaud dot fr
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: yann at droneaud dot fr @ 2009-11-09 17:00 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From yann at droneaud dot fr  2009-11-09 16:59 -------
Created an attachment (id=4371)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4371&action=view)
Proposed test case

Here is a test case which try fscanf() and fgetc() on an any filename given as
argument.

Here are some outputs from the test case:

  $ ./stdio-errno /dev/null
  >>> fscanf() failed: 25 Inappropriate ioctl for device
  fscanf() returned EOF
  >>> fgetc() failed: 25 Inappropriate ioctl for device
  fgetc() returned EOF

  $ ./stdio-errno /dev/zero
  fscanf() failed to parse anything
  >>> fgetc() failed: 25 Inappropriate ioctl for device
  fgetc() returned 0 (0x00000000)

In case of error or EOF, fscanf() is supposed to return EOF. 

But when reading /dev/null, EOF is returned, but errno is set to something
different than 0, eg ENOTTY. This is not usable to distinguish valid EOF.

When reading /dev/zero, fgetc() return 0 which is OK, but set errno to ENOTTY.


-- 


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

------- 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] 6+ messages in thread

end of thread, other threads:[~2014-07-01  5:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-10932-131@http.sourceware.org/bugzilla/>
2014-07-01  5:27 ` [Bug libc/10932] libio use isatty() but don't take care of -ENOTTY fweimer at redhat dot com
2009-11-09 16:42 [Bug libc/10932] New: " yann at droneaud dot fr
2009-11-09 17:00 ` [Bug libc/10932] " yann at droneaud dot fr
2009-11-09 17:02 ` yann at droneaud dot fr
2009-11-09 17:11 ` yann at droneaud dot fr
2009-11-09 21:56 ` yann at droneaud dot fr
2009-11-10 10:18 ` schwab at linux-m68k dot org

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).