msvcrt: Old versions of _vsnprintf() treat the size as a signed int.

When they see -1 they consider that the buffer is too small and return
an error. So impose a 2 GB limit on sprintf() for backward
compatibility with XP and 2003.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2020-02-20 19:27:49 +01:00 committed by Alexandre Julliard
parent 7df0f4a1da
commit c2404ba333

View file

@ -286,7 +286,7 @@ static inline int WINAPIV sprintf(char *buffer, const char *format, ...)
__ms_va_list args;
__ms_va_start(args, format);
ret = _vsnprintf(buffer, (size_t)-1, format, args);
ret = _vsnprintf(buffer, (size_t)_CRT_INT_MAX, format, args);
__ms_va_end(args);
return ret;
}