glibc/libio-wdo-write.patch
Andreas Schwab 7d11a51c51 Accepting request 1136423 from home:Andreas_Schwab:Factory
- sem-open-o-creat.patch: sem_open: Clear O_CREAT when semaphore file is
  expected to exist (BZ #30789)
- ldconfig-process-elf-file.patch: elf: Fix wrong break removal from
  8ee878592c
- tls-modid-reuse.patch: elf: Fix TLS modid reuse generation assignment
  (BZ #29039)
- getaddrinfo-eai-memory.patch: getaddrinfo: translate ENOMEM to
  EAI_MEMORY (bsc#1217589, BZ #31163)
- libio-wdo-write.patch: libio: Check remaining buffer size in
  _IO_wdo_write (BZ #31183)

OBS-URL: https://build.opensuse.org/request/show/1136423
OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=688
2024-01-03 09:37:21 +00:00

37 lines
1.3 KiB
Diff

From cfe121910013a46e2477562282c56ae8062089aa Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Tue, 2 Jan 2024 14:36:17 +0100
Subject: [PATCH] libio: Check remaining buffer size in _IO_wdo_write (bug
31183)
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)").
(cherry picked from commit ecc7c3deb9f347649c2078fcc0f94d4cedf92d60)
---
NEWS | 1 +
libio/wfileops.c | 2 +-
2 files changed, 2 insertions(+), 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. */
--
2.43.0