Bug 4359 - the __freading function is not compatible with Solaris
Summary: the __freading function is not compatible with Solaris
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.3.6
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-13 23:04 UTC by Bruno Haible
Modified: 2014-07-14 09:20 UTC (History)
1 user (show)

See Also:
Host: i586-suse-linux
Target: i586-suse-linux
Build: i586-suse-linux
Last reconfirmed:
fweimer: security-


Attachments
source code of test program (256 bytes, text/plain)
2007-04-13 23:05 UTC, Bruno Haible
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2007-04-13 23:04:21 UTC
The comments in <stdio_ext.h> indicate that the functions declared in this
file are intended to be Solaris compatible. However, __freadable is not.

Attached program prints on Solaris:

Initial state for write-only stream: 0 1
Initial state for read-only stream:  1 0
Initial state for read-write stream: 0 0
Initial state for read-write stream: 0 0

And on a glibc system:

Initial state for write-only stream: 1 1
Initial state for read-only stream:  1 0
Initial state for read-write stream: 1 0
Initial state for read-write stream: 1 0
Comment 1 Bruno Haible 2007-04-13 23:05:11 UTC
Created attachment 1679 [details]
source code of test program
Comment 2 Bruno Haible 2007-04-13 23:07:13 UTC
Oops, I meant __freading, not __freadable.
Comment 3 Ulrich Drepper 2007-10-13 07:21:23 UTC
While I don't quite see why it's needed (libio simply puts new streams in
read-mode) I added appropriate changes.
Comment 4 Bruno Haible 2007-10-13 11:12:53 UTC
Thank you. This change allows to describe what __freading returns in a quite
precise way, as follows. Also, it makes __freading symmetric to __fwriting.


/* Return true if the stream STREAM is opened read-only, or if the
   last operation on the stream was a read operation.  Return false if
   the stream is opened write-only or append-only, or if it supports
   writing and there is no current read operation (such as fputc).

   freading and fwriting will never both be true.  If STREAM supports
   both reads and writes, then:
     - both freading and fwriting might be false when the stream is first
       opened, after read encounters EOF, or after fflush,
     - freading might be false or true and fwriting might be false
       after repositioning (such as fseek, fsetpos, or rewind),
   depending on the underlying implementation.  */
extern int __freading (FILE *stream);