Red Hat Bugzilla – Bug 54577
fscanf() != EOF for empty file
Last modified: 2016-11-24 10:06:05 EST
Description of Problem:
fscanf does not return EOF if attempt to read fro 0 length file
Version-Release number of selected component (if applicable):
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
on linux6.2 fscanf returns EOF
feof(filehandle) is also wrong!
I'm new to Linux but have experience in C
Can you come up with a testcase?
It depends on what arguments fscanf gets.
Created attachment 34422 [details]
source code that demonstrates EOF problem in fscanf
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
I performed the standard 7.0 installation.
rpm shows glibc 2.1.92
glibc-2.2.4-19 fixes the problem! Thanks.