diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-08 10:08:25 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-08 10:08:25 +0000 |
commit | 41dfb5c63862857dadc816caea4bcb4fb268cdf1 (patch) | |
tree | c8ac7b012db7424009fe2956ab62141c633b26e6 /stdio-common/vfscanf.c | |
parent | 027dc27eb964405dd710dba8c5bf9ea33a2e6fcd (diff) |
[BZ #4745]
* stdio-common/vfscanf.c (_IO_vfscanf): Add additional test for EOF
in loop to look for conversion specifier to avoid testing of
wrong errno value.
* stdio-common/Makefile (tests): Add bug18, bug18a, bug19, bug19a.
* stdio-common/bug18.c: New file.
* stdio-common/bug18a.c: New file.
* stdio-common/bug19.c: New file.
* stdio-common/bug19a.c: New file.
Diffstat (limited to 'stdio-common/vfscanf.c')
-rw-r--r-- | stdio-common/vfscanf.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index b1469b9a9e..9e6daced5d 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -530,12 +530,17 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, { /* Eat whitespace. */ int save_errno = errno; - errno = 0; + __set_errno (0); do - if (__builtin_expect (inchar () == EOF && errno == EINTR, 0)) + /* We add the additional test for EOF here since otherwise + inchar will restore the old errno value which might be + EINTR but does not indicate an interrupt since nothing + was read at this time. */ + if (__builtin_expect ((c == EOF || inchar () == EOF) + && errno == EINTR, 0)) input_error (); while (ISSPACE (c)); - errno = save_errno; + __set_errno (save_errno); ungetc (c, s); skip_space = 0; } |