msvcrt: Fix buffer overflow in _write function.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49770
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-09-15 11:55:37 +02:00 committed by Alexandre Julliard
parent ff1a4e0624
commit 427e2bb609
1 changed files with 2 additions and 1 deletions

View File

@ -3504,7 +3504,8 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count)
} }
#endif #endif
for (; i < count && j < sizeof(conv)-1; i++, j++, len++) for (; i < count && j < sizeof(conv)-1 &&
len < (sizeof(lfbuf) - 1) / sizeof(WCHAR); i++, j++, len++)
{ {
if (MSVCRT_isleadbyte((unsigned char)s[i])) if (MSVCRT_isleadbyte((unsigned char)s[i]))
{ {