msvcrt: Fix _vs{w,n}printf_c function when terminating character doesn't fit into buffer.

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 17:40:08 +02:00 committed by Alexandre Julliard
parent 427e2bb609
commit 8b7eedc180
8 changed files with 66 additions and 24 deletions

View File

@ -1454,8 +1454,8 @@
@ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p @ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p
@ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l @ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l
@ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
@ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf_c
@ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_c_l
@ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
@ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
@ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ -1468,8 +1468,8 @@
@ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l @ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l
@ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l @ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l
@ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf @ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf
@ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vswprintf_c
@ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vsnwprintf_l @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_c_l
@ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l @ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l
@ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p @ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p
@ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l

View File

@ -1811,8 +1811,8 @@
@ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p @ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p
@ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l @ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l
@ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
@ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf_c
@ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_c_l
@ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
@ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
@ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ -1825,8 +1825,8 @@
@ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l @ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l
@ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l @ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l
@ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf @ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf
@ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vswprintf_c
@ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vsnwprintf_l @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_c_l
@ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l @ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l
@ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p @ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p
@ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l

View File

@ -1829,8 +1829,8 @@
@ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p @ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p
@ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l @ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l
@ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
@ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf_c
@ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_c_l
@ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
@ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
@ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ -1843,8 +1843,8 @@
@ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l @ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l
@ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l @ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l
@ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf @ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf
@ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vswprintf_c
@ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vsnwprintf_l @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_c_l
@ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l @ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l
@ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p @ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p
@ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l

View File

@ -1133,8 +1133,8 @@
@ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p @ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p
@ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l @ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l
@ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
@ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf_c
@ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_c_l
@ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
@ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
@ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ -1147,8 +1147,8 @@
@ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l @ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l
@ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l @ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l
@ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf @ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf
@ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vswprintf_c
@ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vsnwprintf_l @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_c_l
@ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l @ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l
@ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p @ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p
@ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l

View File

@ -1109,8 +1109,8 @@
@ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p @ cdecl _vscwprintf_p(wstr ptr) MSVCRT__vscwprintf_p
@ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l @ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l
@ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
@ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf_c
@ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_c_l
@ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
@ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
@ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ -1123,8 +1123,8 @@
@ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l @ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l
@ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l @ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l
@ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf @ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf
@ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vswprintf_c
@ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vsnwprintf_l @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_c_l
@ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l @ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l
@ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p @ cdecl _vswprintf_p(ptr long wstr ptr) MSVCRT__vswprintf_p
@ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l

View File

@ -1063,8 +1063,8 @@
@ cdecl _vscwprintf_l(wstr ptr ptr) MSVCRT__vscwprintf_l @ cdecl _vscwprintf_l(wstr ptr ptr) MSVCRT__vscwprintf_l
@ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l @ cdecl _vscwprintf_p_l(wstr ptr ptr) MSVCRT__vscwprintf_p_l
@ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf @ cdecl -norelay _vsnprintf(ptr long str ptr) MSVCRT_vsnprintf
@ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf @ cdecl _vsnprintf_c(ptr long str ptr) MSVCRT_vsnprintf_c
@ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_c_l(ptr long str ptr ptr) MSVCRT_vsnprintf_c_l
@ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l @ cdecl _vsnprintf_l(ptr long str ptr ptr) MSVCRT_vsnprintf_l
@ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s @ cdecl _vsnprintf_s(ptr long long str ptr) MSVCRT_vsnprintf_s
@ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l @ cdecl _vsnprintf_s_l(ptr long long str ptr ptr) MSVCRT_vsnprintf_s_l
@ -1077,8 +1077,8 @@
@ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l @ cdecl _vsprintf_p_l(ptr long str ptr ptr) MSVCRT_vsprintf_p_l
@ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l @ cdecl _vsprintf_s_l(ptr long str ptr ptr) MSVCRT_vsprintf_s_l
@ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf @ cdecl _vswprintf(ptr wstr ptr) MSVCRT_vswprintf
@ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vsnwprintf @ cdecl _vswprintf_c(ptr long wstr ptr) MSVCRT_vswprintf_c
@ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vsnwprintf_l @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_c_l
@ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l @ cdecl _vswprintf_l(ptr wstr ptr ptr) MSVCRT_vswprintf_l
@ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_p_l
@ cdecl _vswprintf_s_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_s_l @ cdecl _vswprintf_s_l(ptr long wstr ptr ptr) MSVCRT_vswprintf_s_l

View File

@ -917,6 +917,11 @@ static void test_vswprintf(void)
ok(ret == 10, "got %d, expected 10\n", ret); ok(ret == 10, "got %d, expected 10\n", ret);
ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf)); ok(!memcmp(buf, out, sizeof(out)), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 'x', sizeof(buf));
ret = _vswprintf_c_wrapper(buf, 10, format, number, 123);
ok(ret == -1, "got %d, expected -1\n", ret);
ok(!wcscmp(buf, L"number 12"), "buf = %s\n", wine_dbgstr_w(buf));
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
ret = _vswprintf_c_l_wrapper(buf, 20, format, NULL, number, 123); ret = _vswprintf_c_l_wrapper(buf, 20, format, NULL, number, 123);
ok(ret == 10, "got %d, expected 10\n", ret); ok(ret == 10, "got %d, expected 10\n", ret);

View File

@ -1010,6 +1010,24 @@ int CDECL MSVCRT_vsnprintf_s( char *str, MSVCRT_size_t sizeOfBuffer,
return MSVCRT_vsnprintf_s_l(str,sizeOfBuffer, count, format, NULL, valist); return MSVCRT_vsnprintf_s_l(str,sizeOfBuffer, count, format, NULL, valist);
} }
/*********************************************************************
* _vsnprintf_c_l (MSVCRT.@)
*/
int CDECL MSVCRT_vsnprintf_c_l(char *str, MSVCRT_size_t len, const char *format,
MSVCRT__locale_t locale, __ms_va_list valist)
{
return MSVCRT_vsnprintf_s_l_opt(str, len, len, format, 0, locale, valist);
}
/*********************************************************************
* _vsnprintf_c (MSVCRT.@)
*/
int CDECL MSVCRT_vsnprintf_c(char *str, MSVCRT_size_t len,
const char *format, __ms_va_list valist)
{
return MSVCRT_vsnprintf_c_l(str, len, format, NULL, valist);
}
#if _MSVCR_VER>=140 #if _MSVCR_VER>=140
/********************************************************************* /*********************************************************************
@ -1218,6 +1236,25 @@ int CDECL MSVCRT_vsnwprintf_l(MSVCRT_wchar_t *str, MSVCRT_size_t len,
return ret; return ret;
} }
/*********************************************************************
* _vswprintf_c_l (MSVCRT.@)
*/
int CDECL MSVCRT_vswprintf_c_l(MSVCRT_wchar_t *str, MSVCRT_size_t len,
const MSVCRT_wchar_t *format, MSVCRT__locale_t locale,
__ms_va_list valist)
{
return MSVCRT_vsnwprintf_s_l_opt(str, len, len, format, 0, locale, valist);
}
/*********************************************************************
* _vswprintf_c (MSVCRT.@)
*/
int CDECL MSVCRT_vswprintf_c(MSVCRT_wchar_t *str, MSVCRT_size_t len,
const MSVCRT_wchar_t *format, __ms_va_list valist)
{
return MSVCRT_vswprintf_c_l(str, len, format, NULL, valist);
}
static int MSVCRT_vswprintf_p_l_opt(MSVCRT_wchar_t *buffer, MSVCRT_size_t length, static int MSVCRT_vswprintf_p_l_opt(MSVCRT_wchar_t *buffer, MSVCRT_size_t length,
const MSVCRT_wchar_t *format, DWORD options, MSVCRT__locale_t locale, __ms_va_list args) const MSVCRT_wchar_t *format, DWORD options, MSVCRT__locale_t locale, __ms_va_list args)
{ {