diff options
author | Florian Weimer <fweimer@redhat.com> | 2022-03-18 21:27:54 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2022-03-18 21:40:02 +0100 |
commit | 88ed43ff0cf2561481de7cba00686386794515d6 (patch) | |
tree | dd91c58f23224c5e63b47cc961a55aa279f6c8d3 /libio/strops.c | |
parent | 6fece2968a11719e8559098d29b4b9519d8cf57a (diff) | |
download | glibc-88ed43ff0cf2561481de7cba00686386794515d6.zip glibc-88ed43ff0cf2561481de7cba00686386794515d6.tar.gz glibc-88ed43ff0cf2561481de7cba00686386794515d6.tar.bz2 |
libio: Flush-only _IO_str_overflow must not return EOF (bug 28949)
In general, _IO_str_overflow returns the character passed as an argument
on success. However, if flush-only operation is requested by passing
EOF, returning EOF looks like an error, and the caller cannot tell
whether the operation was successful or not.
_IO_wstr_overflow had the same bug regarding WEOF.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'libio/strops.c')
-rw-r--r-- | libio/strops.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libio/strops.c b/libio/strops.c index 6a9a884..1cd0bf6 100644 --- a/libio/strops.c +++ b/libio/strops.c @@ -133,7 +133,10 @@ _IO_str_overflow (FILE *fp, int c) *fp->_IO_write_ptr++ = (unsigned char) c; if (fp->_IO_write_ptr > fp->_IO_read_end) fp->_IO_read_end = fp->_IO_write_ptr; - return c; + if (flush_only) + return 0; + else + return c; } libc_hidden_def (_IO_str_overflow) |