freebsd-dev/contrib/netbsd-tests/lib
Kyle Evans 2f489a509e libc: fix some overflow scenarios in vis(3)
The previous incarnation of this would call wcrtomb() on the destination
buffer, and only check for overflow *after* it's happened.
Additionally, the conversion error / VIS_NOLOCALE path also didn't check
for overflow, and the overflow check at the end didn't account for the
fact that we still need to write a NUL terminator afterward.

Start by only doing the multibyte conversion into mbdst directly if we
have enough buffer space to guarantee it'll fit.  An additional
MB_CUR_MAX buffer has been stashed on the stack to write into if we're
cutting it close at the end of the buffer, since we don't really have a
good way to determine the length of the wchar_t without just doing the
conversion.  We'll do the conversion into the buffer that's guaranteed
to fit, then copy it over if the copy won't overflow.

The byte-for-byte overflow is a little bit easier, as we simply check
for overflow with each byte written and make sure we can still NUL
terminate after.

Tests added to exercise these edge cases.

Reviewed by:	des
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41328
2023-08-08 12:01:52 -05:00
..
csu
libbluetooth
libbpfjit
libc libc: fix some overflow scenarios in vis(3) 2023-08-08 12:01:52 -05:00
libcrypt
libcurses
libdes
libevent
libexecinfo libexecinfo: Enable backtrace_test.backtrace_fmt_basic on amd64 again 2023-06-29 19:53:07 +03:00
libm lib/msun: Allow building tests with WARNS=6 2021-03-22 11:55:07 +00:00
libobjc
libposix
libppath
libprop
libpthread h_resolv: Fix a buffer overflow in load(). 2022-12-28 09:39:18 -08:00
libpthread_dbg
librefuse
librt time_t is pathological: use %j + cast to print it. 2021-10-01 12:16:10 -06:00
librumpclient
librumphijack
libskey
libsljit
libusbhid
libutil
semaphore