Bug 54577 - fscanf() != EOF for empty file
fscanf() != EOF for empty file
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2001-10-12 16:22 EDT by Need Real Name
Modified: 2007-04-18 12:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-10-19 13:25:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
source code that demonstrates EOF problem in fscanf (936 bytes, text/plain)
2001-10-19 13:25 EDT, Need Real Name
no flags Details

  None (edit)
Description Need Real Name 2001-10-12 16:22:40 EDT
Description of Problem:
fscanf does not return EOF if attempt to read fro 0 length file

Version-Release number of selected component (if applicable):
 rpm 2.1.19-14

How Reproducible:

Steps to Reproduce:
1. open file for writing, then close file
2. open file for read (filehandle != NULL)
3. fscanf(filehandle) returns 0 not EOF as expected

Actual Results:
returns 0

Expected Results:
expect EOF

Additional Information:
on linux6.2 fscanf returns EOF
feof(filehandle) is also wrong!
I'm new to Linux but have experience in C
Comment 1 Jakub Jelinek 2001-10-15 05:19:30 EDT
Can you come up with a testcase?
It depends on what arguments fscanf gets.
Comment 2 Need Real Name 2001-10-19 13:25:46 EDT
Created attachment 34422 [details]
source code that demonstrates EOF problem in fscanf
Comment 3 Jakub Jelinek 2001-10-19 16:28:04 EDT
What glibc do you use?
Under glibc-2.2.4-19 (which is the same source as 2.2.4-18.7.0,
latest 7.0 errata), I get:
fscanf result is -1, EOF value is -1
Comment 4 Need Real Name 2001-10-19 17:29:09 EDT
I performed the standard 7.0 installation.

rpm shows glibc 2.1.92
Comment 5 Need Real Name 2001-10-23 17:53:14 EDT
glibc-2.2.4-19 fixes the problem! Thanks.

Note You need to log in before you can comment on or make changes to this bug.