From 88ed43ff0cf2561481de7cba00686386794515d6 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 18 Mar 2022 21:27:54 +0100 Subject: 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 --- libio/wstrops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libio/wstrops.c') diff --git a/libio/wstrops.c b/libio/wstrops.c index 8e44f86..2aec3149 100644 --- a/libio/wstrops.c +++ b/libio/wstrops.c @@ -130,7 +130,10 @@ _IO_wstr_overflow (FILE *fp, wint_t c) *fp->_wide_data->_IO_write_ptr++ = c; if (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_read_end) fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_write_ptr; - return c; + if (flush_only) + return 0; + else + return c; } -- cgit v1.1