summaryrefslogtreecommitdiff
path: root/stdio-common/wprintf_buffer_flush.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-08-18 08:49:55 +0200
committerFlorian Weimer <fweimer@redhat.com>2022-12-12 15:40:20 +0100
commitb30518eedbce705f9f34970ff459083d738d2e36 (patch)
tree28c7c95320f1123e38cde445a4f43b9622c4f59a /stdio-common/wprintf_buffer_flush.c
parent45234c5d6ba9556451424940fa746e9e66b1a6f4 (diff)
downloadglibc-fw/vfprintf-2.tar.gz
libio: Convert __vswprintf_internal to buffers (bug 27857)fw/vfprintf-2
Always null-terminate the buffer and set E2BIG if the buffer is too small. This fixes bug 27857.
Diffstat (limited to 'stdio-common/wprintf_buffer_flush.c')
-rw-r--r--stdio-common/wprintf_buffer_flush.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/stdio-common/wprintf_buffer_flush.c b/stdio-common/wprintf_buffer_flush.c
index 2d91095cca..46af0f348f 100644
--- a/stdio-common/wprintf_buffer_flush.c
+++ b/stdio-common/wprintf_buffer_flush.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <errno.h>
#include <printf_buffer.h>
#include "printf_buffer-wchar_t.h"
@@ -31,6 +32,11 @@ __wprintf_buffer_do_flush (struct __wprintf_buffer *buf)
case __wprintf_buffer_mode_to_file:
__wprintf_buffer_flush_to_file ((struct __wprintf_buffer_to_file *) buf);
return;
+ case __wprintf_buffer_mode_swprintf:
+ buf->write_end[-1] = L'\0';
+ __set_errno (E2BIG);
+ __wprintf_buffer_mark_failed (buf);
+ return;
}
__builtin_trap ();
}