* [PATCH] libio: Check remaining buffer size in _IO_wdo_write (bug 31183)
@ 2023-12-20 16:10 Florian Weimer
2024-01-02 10:10 ` Andreas Schwab
0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2023-12-20 16:10 UTC (permalink / raw)
To: libc-alpha; +Cc: Andreas Schwab
The multibyte character needs to fit into the remaining buffer space,
not the already-written buffer space. Without the fix, we were never
moving the write pointer from the start of the buffer, always using
the single-character fallback buffer.
Fixes commit 04b76b5aa8b2d1d19066e42dd1 ("Don't error out writing
a multibyte character to an unbuffered stream (bug 17522)").
---
libio/wfileops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libio/wfileops.c b/libio/wfileops.c
index f16f6db1c3..9ab8f2e7f3 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -55,7 +55,7 @@ _IO_wdo_write (FILE *fp, const wchar_t *data, size_t to_do)
char mb_buf[MB_LEN_MAX];
char *write_base, *write_ptr, *buf_end;
- if (fp->_IO_write_ptr - fp->_IO_write_base < sizeof (mb_buf))
+ if (fp->_IO_buf_end - fp->_IO_write_ptr < sizeof (mb_buf))
{
/* Make sure we have room for at least one multibyte
character. */
base-commit: 61bac1a9d2ab80ebcbc51484722e6ea43414bec7
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libio: Check remaining buffer size in _IO_wdo_write (bug 31183)
2023-12-20 16:10 [PATCH] libio: Check remaining buffer size in _IO_wdo_write (bug 31183) Florian Weimer
@ 2024-01-02 10:10 ` Andreas Schwab
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2024-01-02 10:10 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Dez 20 2023, Florian Weimer wrote:
> The multibyte character needs to fit into the remaining buffer space,
> not the already-written buffer space. Without the fix, we were never
> moving the write pointer from the start of the buffer, always using
> the single-character fallback buffer.
>
> Fixes commit 04b76b5aa8b2d1d19066e42dd1 ("Don't error out writing
> a multibyte character to an unbuffered stream (bug 17522)").
Ok.
I don't know how I managed to get that so wrong.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-02 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-20 16:10 [PATCH] libio: Check remaining buffer size in _IO_wdo_write (bug 31183) Florian Weimer
2024-01-02 10:10 ` Andreas Schwab
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).