public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] libio: Flush-only _IO_str_overflow must not return EOF (bug 28949) Date: Fri, 18 Mar 2022 20:42:22 +0000 (GMT) [thread overview] Message-ID: <20220318204222.9D19C3889819@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=88ed43ff0cf2561481de7cba00686386794515d6 commit 88ed43ff0cf2561481de7cba00686386794515d6 Author: Florian Weimer <fweimer@redhat.com> Date: Fri Mar 18 21:27:54 2022 +0100 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> Diff: --- libio/strops.c | 5 ++++- libio/wstrops.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libio/strops.c b/libio/strops.c index 6a9a8846c4..1cd0bf6c3d 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) diff --git a/libio/wstrops.c b/libio/wstrops.c index 8e44f86c35..2aec314937 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; }
reply other threads:[~2022-03-18 20:42 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220318204222.9D19C3889819@sourceware.org \ --to=fw@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).