1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

libio: Convert __vswprintf_internal to buffers (bug 27857)

Always null-terminate the buffer and set E2BIG if the buffer is too
small.  This fixes bug 27857.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Florian Weimer
2022-12-19 18:56:55 +01:00
parent 5365acc567
commit 118816de33
6 changed files with 57 additions and 89 deletions

View File

@ -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 ();
}