Warn usage of (v)sprintf (v2)
Until all projects using this are reviewed, please keep this warning in place. Signed-off-by: Simon Rozman <simon.rozman@amebis.si>
This commit is contained in:
@@ -252,8 +252,8 @@ inline SIZE_T SIZETAdd(SIZE_T a, SIZE_T b)
|
||||
///
|
||||
/// \returns Number of characters in result.
|
||||
///
|
||||
[[deprecated("Behavior of this function changed from append to assign. Please, review call usage.")]]
|
||||
template<class _Traits, class _Ax>
|
||||
[[deprecated("Behavior of this function changed from append to assign. Please, review call usage.")]]
|
||||
static int vsprintf(_Inout_ std::basic_string<char, _Traits, _Ax> &str, _In_z_ _Printf_format_string_ const char *format, _In_ va_list arg)
|
||||
{
|
||||
char buf[WINSTD_STACK_BUFFER_BYTES/sizeof(char)];
|
||||
@@ -291,8 +291,8 @@ static int vsprintf(_Inout_ std::basic_string<char, _Traits, _Ax> &str, _In_z_ _
|
||||
///
|
||||
/// \returns Number of characters in result.
|
||||
///
|
||||
[[deprecated("Behavior of this function changed from append to assign. Please, review call usage.")]]
|
||||
template<class _Traits, class _Ax>
|
||||
[[deprecated("Behavior of this function changed from append to assign. Please, review call usage.")]]
|
||||
static int vsprintf(_Inout_ std::basic_string<wchar_t, _Traits, _Ax> &str, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg)
|
||||
{
|
||||
wchar_t buf[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)];
|
||||
@@ -1312,6 +1312,7 @@ namespace winstd
|
||||
va_list arg;
|
||||
va_start(arg, wLanguage);
|
||||
std::wstring sMessage;
|
||||
#pragma warning(suppress: 4996) // Checked to comply.
|
||||
vsprintf(sMessage, szFormat, arg);
|
||||
va_end(arg);
|
||||
WideCharToMultiByte(CP_UTF8, 0, sMessage, sResult, NULL, NULL);
|
||||
@@ -1498,6 +1499,7 @@ namespace winstd
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
#pragma warning(suppress: 4996) // Checked to comply.
|
||||
vsprintf(*this, format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
@@ -739,7 +739,8 @@ static _Success_(return != 0) int LoadStringW(_In_opt_ HINSTANCE hInstance, _In_
|
||||
static VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) noexcept
|
||||
{
|
||||
std::string str;
|
||||
try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
|
||||
#pragma warning(suppress: 4996) // Checked to comply.
|
||||
try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
|
||||
OutputDebugStringA(str.c_str());
|
||||
}
|
||||
|
||||
@@ -751,7 +752,8 @@ static VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) noex
|
||||
static VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg) noexcept
|
||||
{
|
||||
std::wstring str;
|
||||
try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
|
||||
#pragma warning(suppress: 4996) // Checked to comply.
|
||||
try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
|
||||
OutputDebugStringW(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user