musl/src/multibyte
Rich Felker 211264e46a fix buffer overflow in mbsrtowcs
issue reported by Michael Forney:

"If wn becomes 0 after processing a chunk of 4, mbsrtowcs currently
continues on, wrapping wn around to -1, causing the rest of the string
to be processed.

This resulted in buffer overruns if there was only space in ws for wn
wide characters."

the original patch submitted added an additional check for !wn after
the loop; to avoid extra branching, I instead just changed the wn>=4
check to wn>=5 to ensure that at least one slot remains after the
word-at-a-time loop runs. this should not slow down the tail
processing on real-world usage, since an extra slot that can't be
processed in the word-at-a-time loop is needed for the null
termination anyway.
2013-09-27 13:09:46 -04:00
..
btowc.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
internal.c new attempt at working around the gcc 3 visibility bug 2012-02-24 20:07:21 -05:00
internal.h fix out-of-bounds access in UTF-8 decoding 2013-04-08 22:29:46 -04:00
mblen.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
mbrlen.c use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
mbrtowc.c mbrtowc: do not leave mbstate_t in permanent-fail state after EILSEQ 2013-04-08 23:09:11 -04:00
mbsinit.c fix failure of mbsinit(0) (not UB; required to return nonzero) 2012-05-26 18:02:45 -04:00
mbsnrtowcs.c use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
mbsrtowcs.c fix buffer overflow in mbsrtowcs 2013-09-27 13:09:46 -04:00
mbstowcs.c cleanup mbstowcs wrapper 2013-04-04 14:53:53 -04:00
mbtowc.c implement mbtowc directly, not as a wrapper for mbrtowc 2013-04-08 23:01:32 -04:00
wcrtomb.c use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
wcsnrtombs.c use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
wcsrtombs.c fix incorrect range checks in wcsrtombs 2013-04-04 14:48:48 -04:00
wcstombs.c cleanup wcstombs 2013-04-04 14:55:42 -04:00
wctob.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00
wctomb.c initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00