diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2016-12-23 14:41:28 +0100 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-12-23 05:41:28 -0800 |
commit | f5cbe4c9cab2873b60cd3c991732a250d2e164a2 (patch) | |
tree | 3dfef3ef56990e19fb914821ed4e6f36c9931fd1 | |
parent | 5ef3df8ffe059d5f91c6bae09d8f95a0332f1363 (diff) | |
download | coreclr-f5cbe4c9cab2873b60cd3c991732a250d2e164a2.tar.gz coreclr-f5cbe4c9cab2873b60cd3c991732a250d2e164a2.tar.bz2 coreclr-f5cbe4c9cab2873b60cd3c991732a250d2e164a2.zip |
Remove all usage of vsnprintf (#8709)
This change removes all usages of vsnprintf and modifies runtime to not to use
vsnprintf or _vsnprintf
I've also fixed two issues in PAL TRACE function string format parameters that
caused crashes when I was trying to run all PAL tests with PAL tracing enabled.
105 files changed, 129 insertions, 1757 deletions
diff --git a/src/ToolBox/SOS/Strike/strike.h b/src/ToolBox/SOS/Strike/strike.h index e070898ff5..dfc0dcfea4 100644 --- a/src/ToolBox/SOS/Strike/strike.h +++ b/src/ToolBox/SOS/Strike/strike.h @@ -44,10 +44,6 @@ #define _wcsstr wcsstr #endif // !PAL_STDCPP_COMPAT -#ifdef PLATFORM_UNIX -#define _vsnprintf vsnprintf -#endif - #define ___in _SAL1_Source_(__in, (), _In_) #define ___out _SAL1_Source_(__out, (), _Out_) diff --git a/src/ToolBox/SOS/Strike/xplat/dbgeng.h b/src/ToolBox/SOS/Strike/xplat/dbgeng.h index b4562271a6..5dcf9572bb 100644 --- a/src/ToolBox/SOS/Strike/xplat/dbgeng.h +++ b/src/ToolBox/SOS/Strike/xplat/dbgeng.h @@ -84,7 +84,7 @@ public: va_list args) { char str[4096]; - int length = PAL__vsnprintf(str, sizeof(str), format, args); + int length = _vsnprintf_s(str, sizeof(str), _TRUNCATE, format, args); if (length > 0) { return Output(mask, "%s", str); diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src index 7d60c1ed4b..ab73c4fcb8 100644 --- a/src/dlls/mscordac/mscordac_unixexports.src +++ b/src/dlls/mscordac/mscordac_unixexports.src @@ -17,7 +17,6 @@ PAL_fflush PAL__flushall PAL_free PAL_fwprintf -PAL_swprintf PAL_GetPALDirectoryW PAL_GetResourceString PAL_get_stdout @@ -35,7 +34,6 @@ PAL_printf PAL_qsort PAL_Reenter PAL_fprintf -PAL__vsnprintf PAL__wcstoui64 PAL_wcstoul PAL_iswprint @@ -52,6 +50,8 @@ _wcsicmp _stricmp sprintf_s swprintf_s +vsprintf_s +_snprintf_s _snwprintf_s _vsnprintf_s _vsnwprintf_s diff --git a/src/gc/env/gcenv.base.h b/src/gc/env/gcenv.base.h index 94f73762f8..0a0de73ee1 100644 --- a/src/gc/env/gcenv.base.h +++ b/src/gc/env/gcenv.base.h @@ -96,7 +96,7 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x) #define UNREFERENCED_PARAMETER(P) (void)(P) #ifdef PLATFORM_UNIX -#define _vsnprintf vsnprintf +#define _vsnprintf_s(string, sizeInBytes, count, format, args) vsnprintf(string, sizeInBytes, format, args) #define sprintf_s snprintf #define swprintf_s swprintf #endif diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 6187938ff8..586da23527 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -389,7 +389,7 @@ void log_va_msg(const char *fmt, va_list args) int pid_len = sprintf_s (&pBuffer[buffer_start], BUFFERSIZE - buffer_start, "[%5d]", (uint32_t)GCToOSInterface::GetCurrentThreadIdForLogging()); buffer_start += pid_len; memset(&pBuffer[buffer_start], '-', BUFFERSIZE - buffer_start); - int msg_len = _vsnprintf(&pBuffer[buffer_start], BUFFERSIZE - buffer_start, fmt, args ); + int msg_len = _vsnprintf_s(&pBuffer[buffer_start], BUFFERSIZE - buffer_start, _TRUNCATE, fmt, args ); if (msg_len == -1) { msg_len = BUFFERSIZE - buffer_start; diff --git a/src/md/compiler/regmeta.cpp b/src/md/compiler/regmeta.cpp index 230d1e4ff0..feb1cdd31b 100644 --- a/src/md/compiler/regmeta.cpp +++ b/src/md/compiler/regmeta.cpp @@ -829,7 +829,10 @@ int DumpMD_VWriteMarker(__in __in_z const char *str, va_list marker) { if (FAILED(hr = m_output.ReSizeNoThrow(STRING_BUFFER_LEN * i))) return 0; - count = _vsnprintf((char *)m_output.Ptr(), STRING_BUFFER_LEN * i, str, marker); + va_list markerCopy; + va_copy(markerCopy, marker); + count = _vsnprintf_s((char *)m_output.Ptr(), STRING_BUFFER_LEN * i, _TRUNCATE, str, markerCopy); + va_end(markerCopy); i *= 2; } OutputDebugStringA((LPCSTR)m_output.Ptr()); diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 05c777c7ca..51ac5b9a5d 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -5640,7 +5640,6 @@ CoCreateGuid(OUT GUID * pguid); #define printf PAL_printf #define vprintf PAL_vprintf #define wprintf PAL_wprintf -#define swprintf PAL_swprintf #define wcsspn PAL_wcsspn #define wcstod PAL_wcstod #define wcstol PAL_wcstol @@ -5667,8 +5666,6 @@ CoCreateGuid(OUT GUID * pguid); #define iswxdigit PAL_iswxdigit #define towlower PAL_towlower #define towupper PAL_towupper -#define vsprintf PAL_vsprintf -#define vswprintf PAL_vswprintf #define realloc PAL_realloc #define fopen PAL_fopen #define strtok PAL_strtok @@ -5731,7 +5728,6 @@ CoCreateGuid(OUT GUID * pguid); #define _close PAL__close #define _wcstoui64 PAL__wcstoui64 #define _flushall PAL__flushall -#define _vsnprintf PAL__vsnprintf #define strnlen PAL_strnlen #ifdef _AMD64_ @@ -5809,7 +5805,6 @@ PALIMPORT char * __cdecl strstr(const char *, const char *); PALIMPORT char * __cdecl strtok(char *, const char *); PALIMPORT size_t __cdecl strspn(const char *, const char *); PALIMPORT size_t __cdecl strcspn(const char *, const char *); -PALIMPORT int __cdecl vsprintf(char *, const char *, va_list); PALIMPORT int __cdecl atoi(const char *); PALIMPORT LONG __cdecl atol(const char *); PALIMPORT ULONG __cdecl strtoul(const char *, char **, int); @@ -5873,7 +5868,6 @@ PALIMPORT WCHAR * __cdecl PAL_wcstok(WCHAR *, const WCHAR *); PALIMPORT size_t __cdecl PAL_wcscspn(const WCHAR *, const WCHAR *); PALIMPORT int __cdecl PAL_swprintf(WCHAR *, const WCHAR *, ...); PALIMPORT int __cdecl PAL_vswprintf(WCHAR *, const WCHAR *, va_list); -PALIMPORT int __cdecl PAL__vsnprintf(LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap); PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...); PALIMPORT LONG __cdecl PAL_wcstol(const WCHAR *, WCHAR **, int); PALIMPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int); diff --git a/src/pal/inc/rt/palrt.h b/src/pal/inc/rt/palrt.h index c181f38c2b..ce637bad0e 100644 --- a/src/pal/inc/rt/palrt.h +++ b/src/pal/inc/rt/palrt.h @@ -893,7 +893,6 @@ Remember to fix the errcode defintion in safecrt.h. */ #define _wcslwr_s _wcslwr_unsafe -#define _snprintf_s _snprintf_unsafe #define swscanf_s swscanf #define _wfopen_s _wfopen_unsafe @@ -903,8 +902,6 @@ Remember to fix the errcode defintion in safecrt.h. #define _vscprintf _vscprintf_unsafe -#define vsprintf_s _vsnprintf - extern "C++" { #include <safemath.h> @@ -959,8 +956,11 @@ inline int __cdecl _vscprintf_unsafe(const char *_Format, va_list _ArgList) if(buf == nullptr) return 0; - int ret = _vsnprintf(buf, guess, _Format, _ArgList); + va_list argListCopy; + va_copy(argListCopy, _ArgList); + int ret = _vsnprintf_s(buf, guess, _TRUNCATE, _Format, argListCopy); free(buf); + va_end(argListCopy); if ((ret != -1) && (ret < guess)) return ret; @@ -969,28 +969,6 @@ inline int __cdecl _vscprintf_unsafe(const char *_Format, va_list _ArgList) } } -inline int __cdecl _vsnprintf_unsafe(char *_Dst, size_t _SizeInWords, size_t _Count, const char *_Format, va_list _ArgList) -{ - if (_Count == _TRUNCATE) _Count = _SizeInWords - 1; - int ret = _vsnprintf(_Dst, _Count, _Format, _ArgList); - _Dst[_SizeInWords - 1] = L'\0'; - if (ret < 0 && errno == 0) - { - errno = ERANGE; - } - return ret; -} - -inline int __cdecl _snprintf_unsafe(char *_Dst, size_t _SizeInWords, size_t _Count, const char *_Format, ...) -{ - int ret; - va_list _ArgList; - va_start(_ArgList, _Format); - ret = _vsnprintf_unsafe(_Dst, _SizeInWords, _Count, _Format, _ArgList); - va_end(_ArgList); - return ret; -} - inline errno_t __cdecl _wfopen_unsafe(PAL_FILE * *ff, const WCHAR *fileName, const WCHAR *mode) { PAL_FILE *result = _wfopen(fileName, mode); diff --git a/src/pal/inc/rt/safecrt.h b/src/pal/inc/rt/safecrt.h index 3cc10cef33..ab3e37ec48 100644 --- a/src/pal/inc/rt/safecrt.h +++ b/src/pal/inc/rt/safecrt.h @@ -3253,10 +3253,6 @@ int __cdecl vswprintf_s(WCHAR (&_Dst)[_SizeInWords], const WCHAR *_Format, va_li * return -1 if the formatted string does not entirely fit into _Dst (we will not call _SAFECRT_INVALID_PARAMETER); * if _Count == 0, then (_Dst == nullptr && _SizeInBytes == 0) is allowed */ -_SAFECRT__EXTERN_C -int __cdecl _snprintf_s(char *_Dst, size_t _SizeInBytes, size_t _Count, const char *_Format, ...); -_SAFECRT__EXTERN_C -int __cdecl _vsnprintf_s(char *_Dst, size_t _SizeInBytes, size_t _Count, const char *_Format, va_list _ArgList); #if defined(__cplusplus) && _SAFECRT_USE_CPP_OVERLOADS template <size_t _SizeInBytes> diff --git a/src/pal/src/cruntime/printf.cpp b/src/pal/src/cruntime/printf.cpp index c437b8e39f..72c7e11bea 100644 --- a/src/pal/src/cruntime/printf.cpp +++ b/src/pal/src/cruntime/printf.cpp @@ -1365,34 +1365,6 @@ int PAL_wvsscanf(LPCWSTR Buffer, LPCWSTR Format, va_list ap) /*++ Function: - PAL_swprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_swprintf( - wchar_16 *buffer, - const wchar_16 *format, - ...) -{ - LONG Length; - va_list ap; - - PERF_ENTRY(swprintf); - ENTRY("PAL_swprintf (buffer=%p, format=%p (%S))\n", buffer, format, format); - - va_start(ap, format); - Length = PAL__wvsnprintf(buffer, 0x7fffffff, format, ap); - va_end(ap); - - LOGEXIT("PAL_swprintf returns int %d\n", Length); - PERF_EXIT(swprintf); - return Length; -} - -/*++ -Function: PAL_swscanf See MSDN doc. @@ -1420,60 +1392,6 @@ PAL_swscanf( } -/*++ -Function: - PAL_vsprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_vsprintf(char *buffer, - const char *format, - va_list argptr) -{ - LONG Length; - - PERF_ENTRY(vsprintf); - ENTRY("PAL_vsprintf (buffer=%p, format=%p (%s), argptr=%p)\n", - buffer, format, format, argptr); - - Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, 0x7fffffff, format, argptr); - - LOGEXIT("PAL_vsprintf returns int %d\n", Length); - PERF_EXIT(vsprintf); - - return Length; -} - - -/*++ -Function: - PAL_vswprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_vswprintf(wchar_16 *buffer, - const wchar_16 *format, - va_list argptr) -{ - LONG Length; - - PERF_ENTRY(vswprintf); - ENTRY("PAL_vswprintf (buffer=%p, format=%p (%S), argptr=%p)\n", - buffer, format, format, argptr); - - Length = PAL__wvsnprintf(buffer, 0x7fffffff, format, argptr); - - LOGEXIT("PAL_vswprintf returns int %d\n", Length); - PERF_EXIT(vswprintf); - - return Length; -} - - #if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT /*++ Function: diff --git a/src/pal/src/cruntime/printfcpp.cpp b/src/pal/src/cruntime/printfcpp.cpp index ea074a604b..85ec698991 100644 --- a/src/pal/src/cruntime/printfcpp.cpp +++ b/src/pal/src/cruntime/printfcpp.cpp @@ -35,8 +35,6 @@ SET_DEFAULT_DEBUG_CHANNEL(CRT); using namespace CorUnix; -int CoreWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap); -int CoreVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap); int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list ap); int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list ap); @@ -1053,49 +1051,6 @@ static INT Internal_AddPaddingVfwprintf(CPalThread *pthrCurrent, PAL_FILE *strea /******************************************************************************* Function: - PAL_vsnprintf - -Parameters: - Buffer - - out buffer - Count - - buffer size - Format - - format string - ap - - stdarg parameter list -*******************************************************************************/ - -int __cdecl PAL__vsnprintf(LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap) -{ - LONG Length; - - PERF_ENTRY(PAL__vsnprintf); - ENTRY("PAL__vsnprintf (buffer=%p, count=%d, format=%p (%s), argptr=%p)\n", - Buffer, Count, Format, Format, ap); - - Length = CoreVsnprintf(InternalGetCurrentThread(), Buffer, Count, Format, ap); - - LOGEXIT("PAL__vsnprintf returns int %d\n", Length); - PERF_EXIT(PAL__vsnprintf); - - return Length; -} - -/******************************************************************************* -Function: - PAL_wvsnprintf - - -- see PAL_vsnprintf above -*******************************************************************************/ - -int __cdecl PAL__wvsnprintf(LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap) -{ - return CoreWvsnprintf(InternalGetCurrentThread(), Buffer, Count, Format, ap); -} - -/******************************************************************************* -Function: PAL_vfprintf Parameters: @@ -1132,26 +1087,11 @@ int __cdecl PAL_vfwprintf(PAL_FILE *stream, const wchar_16 *format, va_list ap) } // end extern "C" -int CorUnix::InternalWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap) -{ - return CoreWvsnprintf(pthrCurrent, Buffer, Count, Format, ap); -} - -int CorUnix::InternalVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap) -{ - return CoreVsnprintf(pthrCurrent, Buffer, Count, Format, ap); -} - int CorUnix::InternalVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list ap) { return CoreVfprintf(pthrCurrent, stream, format, ap); } -int CorUnix::InternalVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list ap) -{ - return CoreVfwprintf(pthrCurrent, stream, format, ap); -} - int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list aparg) { CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */ @@ -1466,7 +1406,7 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for va_list apcopy; va_copy(apcopy, ap); - TempInt = vsnprintf(TempSprintfStr, TEMP_COUNT, TempBuff, apcopy); + TempInt = _vsnprintf_s(TempSprintfStr, TEMP_COUNT, _TRUNCATE, TempBuff, apcopy); va_end(apcopy); PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); @@ -1484,7 +1424,7 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for TempSprintfStr = TempSprintfStrPtr; va_copy(apcopy, ap); - vsnprintf(TempSprintfStr, TempInt, TempBuff, apcopy); + _vsnprintf_s(TempSprintfStr, TempInt, _TRUNCATE, TempBuff, apcopy); va_end(apcopy); PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); } @@ -1581,664 +1521,6 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for return (written); } -int CoreVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list aparg) -{ - BOOL BufferRanOut = FALSE; - CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */ - LPSTR BufferPtr = Buffer; - LPCSTR Fmt = Format; - LPWSTR TempWStr; - LPSTR TempStr; - WCHAR TempWChar; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT Length; - INT TempInt; - int wctombResult; - va_list ap; - - va_copy(ap, aparg); - - while (*Fmt) - { - if (BufferRanOut || (BufferPtr - Buffer) >= static_cast<int>(Count)) //Count is assumed to be in the range of int - { - BufferRanOut = TRUE; - break; - } - else if(*Fmt == '%' && - TRUE == Internal_ExtractFormatA(pthrCurrent, &Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_STRING) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWStr = va_arg(ap, LPWSTR); - Length = WideCharToMultiByte(CP_ACP, 0, TempWStr, -1, 0, - 0, 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - va_end(ap); - return -1; - } - TempStr = (LPSTR) InternalMalloc(Length); - if (!TempStr) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - if (PRECISION_DOT == Precision) - { - /* copy nothing */ - *TempStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length - 1) - { - Length = WideCharToMultiByte(CP_ACP, 0, TempWStr, - Precision, TempStr, Length, - 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - free(TempStr); - va_end(ap); - return -1; - } - TempStr[Length] = 0; - Length = Precision; - } - /* copy everything */ - else - { - wctombResult = WideCharToMultiByte(CP_ACP, 0, TempWStr, -1, - TempStr, Length, 0, 0); - if (!wctombResult) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - free(TempStr); - va_end(ap); - return -1; - } - --Length; /* exclude null char */ - } - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempStr, - Width - Length, - Flags); - - free(TempStr); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - CHAR TempBuffer[5]; - - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar = va_arg(ap, int); - Length = WideCharToMultiByte(CP_ACP, 0, &TempWChar, 1, - TempBuffer, sizeof(TempBuffer), - 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - va_end(ap); - return -1; - } - TempBuffer[Length] = 0; - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempBuffer, - Width - Length, - Flags); - - } - /* this places the number of bytes written to the buffer in the - next arg */ - else if (Type == PFF_TYPE_N) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - - if (Prefix == PFF_PREFIX_SHORT) - { - *(va_arg(ap, short *)) = BufferPtr - Buffer; - } - else - { - *(va_arg(ap, LPLONG)) = BufferPtr - Buffer; - } - } - else if (Type == PFF_TYPE_CHAR && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded chars, - // so we handle them here. - char ch[2]; - - ch[0] = (char) va_arg(ap, int); - ch[1] = '\0'; - Length = 1; - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - ch, - Width - Length, - Flags); - } - else if (Type == PFF_TYPE_STRING && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded strings, - // so we handle them here. - char *tempStr; - - tempStr = va_arg(ap, char *); - Length = strlen(tempStr); - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - tempStr, - Width - Length, - Flags); - } - else - { - // Types that sprintf can handle - size_t TempCount = Count - (BufferPtr - Buffer); - -#if !HAVE_LARGE_SNPRINTF_SUPPORT - // Limit TempCount to 0x40000000, which is sufficient - // for platforms on which snprintf fails for very large - // sizes. - if (TempCount > 0x40000000) - { - TempCount = 0x40000000; - } -#endif // HAVE_LARGE_SNPRINTF_SUPPORT - - TempInt = 0; - // %h (short) doesn't seem to be handled properly by local sprintf, - // so we do the truncation ourselves for some cases. - if (Type == PFF_TYPE_P && Prefix == PFF_PREFIX_SHORT) - { - // Convert from pointer -> int -> short to avoid warnings. - long trunc1; - short trunc2; - - trunc1 = va_arg(ap, LONG); - trunc2 = (short) trunc1; - trunc1 = trunc2; - - TempInt = snprintf(BufferPtr, TempCount, TempBuff, trunc1); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short) n; - - TempInt = snprintf(BufferPtr, TempCount, TempBuff, s); - } - else - { - va_list apcopy; - va_copy(apcopy, ap); - TempInt = vsnprintf(BufferPtr, TempCount, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (TempInt < 0 || static_cast<size_t>(TempInt) >= TempCount) /* buffer not long enough */ - { - BufferPtr += TempCount; - BufferRanOut = TRUE; - } - else - { - BufferPtr += TempInt; - } - } - } - else - { - *BufferPtr++ = *Fmt++; /* copy regular chars into buffer */ - } - } - - if (static_cast<int>(Count) > (BufferPtr - Buffer)) //Count is assumed to be in the range of int - { - *BufferPtr = 0; /* end the string */ - } - - va_end(ap); - - if (BufferRanOut) - { - errno = ERANGE; - return -1; - } - else - { - return BufferPtr - Buffer; - } -} - -int CoreWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list aparg) -{ - BOOL BufferRanOut = FALSE; - CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */ - LPWSTR BufferPtr = Buffer; - LPCWSTR Fmt = Format; - LPWSTR TempWStr = NULL; - LPWSTR WorkingWStr = NULL; - WCHAR TempWChar[2]; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT TempInt; - LPSTR TempNumberBuffer; - int mbtowcResult; - va_list(ap); - - PERF_ENTRY(wvsnprintf); - ENTRY("wvsnprintf (buffer=%p, count=%u, format=%p (%S))\n", - Buffer, Count, Format, Format); - - va_copy(ap, aparg); - - while (*Fmt) - { - if (BufferRanOut || (BufferPtr - Buffer) >= static_cast<int>(Count)) //Count is assumed to be in the range of int - { - BufferRanOut = TRUE; - break; - } - else if(*Fmt == '%' && - TRUE == Internal_ExtractFormatW(pthrCurrent, &Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (((Prefix == PFF_PREFIX_LONG || Prefix == PFF_PREFIX_LONG_W) && - (Type == PFF_TYPE_STRING || Type == PFF_TYPE_WSTRING)) || - (Prefix == PFF_PREFIX_SHORT && Type == PFF_TYPE_STRING) || - (Type == PFF_TYPE_WSTRING && (Flags & PFF_ZERO) != 0)) - { - BOOL needToFree = FALSE; - - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if ((Type == PFF_TYPE_STRING && Prefix == PFF_PREFIX_LONG) || - Prefix == PFF_PREFIX_LONG_W) - { - TempWStr = va_arg(ap, LPWSTR); - } - else - { - // %lS and %hs assume an LPSTR argument. - LPSTR s = va_arg(ap, LPSTR ); - UINT Length = 0; - Length = MultiByteToWideChar( CP_ACP, 0, s, -1, NULL, 0 ); - if ( Length != 0 ) - { - TempWStr = - (LPWSTR)InternalMalloc((Length + 1 ) * sizeof( WCHAR ) ); - if ( TempWStr ) - { - needToFree = TRUE; - MultiByteToWideChar( CP_ACP, 0, s, -1, - TempWStr, Length ); - } - else - { - ERROR( "InternalMalloc failed.\n" ); - va_end(ap); - return -1; - } - } - else - { - ASSERT( "Unable to convert from multibyte " - " to wide char.\n" ); - va_end(ap); - return -1; - } - - } - - INT Length = PAL_wcslen(TempWStr); - WorkingWStr = (LPWSTR) InternalMalloc(sizeof(WCHAR) * (Length + 1)); - if (!WorkingWStr) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - if (needToFree) - { - free(TempWStr); - } - va_end(ap); - return -1; - } - if (PRECISION_DOT == Precision) - { - // Copy nothing - *WorkingWStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length) - { - if (wcsncpy_s(WorkingWStr, (Length + 1), TempWStr, Precision+1) != SAFECRT_SUCCESS) - { - ERROR("CoreWvsnprintf failed\n"); - if (needToFree) - { - free(TempWStr); - } - free(WorkingWStr); - LOGEXIT("wcsncpy_s failed!\n"); - PERF_EXIT(wvsnprintf); - va_end(ap); - return (-1); - } - - Length = Precision; - } - else - { - // Copy everything - PAL_wcscpy(WorkingWStr, TempWStr); - } - - // Add padding if needed. - BufferRanOut = !Internal_AddPaddingW(&BufferPtr, - Count - (BufferPtr - Buffer), - WorkingWStr, - Width - Length, - Flags); - - if (needToFree) - { - free(TempWStr); - } - free(WorkingWStr); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar[0] = va_arg(ap, int); - TempWChar[1] = 0; - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingW(&BufferPtr, - Count - (BufferPtr - Buffer), - TempWChar, - Width - 1, - Flags); - - } - /* this places the number of bytes written to the buffer in the - next arg */ - else if (Type == PFF_TYPE_N) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - - if (Prefix == PFF_PREFIX_SHORT) - { - *(va_arg(ap, short *)) = BufferPtr - Buffer; - } - else - { - *(va_arg(ap, LPLONG)) = BufferPtr - Buffer; - } - } - else - { - // Types that sprintf can handle - - /* note: I'm using the wide buffer as a (char *) buffer when I - pass it to sprintf(). After I get the buffer back I make a - backup of the chars copied and then convert them to wide - and place them in the buffer (BufferPtr) */ - size_t TempCount = Count - (BufferPtr - Buffer); - TempInt = 0; - -#if !HAVE_LARGE_SNPRINTF_SUPPORT - // Limit TempCount to 0x40000000, which is sufficient - // for platforms on which snprintf fails for very large - // sizes. - if (TempCount > 0x40000000) - { - TempCount = 0x40000000; - } -#endif // HAVE_LARGE_SNPRINTF_SUPPORT - - // %h (short) doesn't seem to be handled properly by local sprintf, - // so we do the truncation ourselves for some cases. - if (Type == PFF_TYPE_P && Prefix == PFF_PREFIX_SHORT) - { - // Convert from pointer -> int -> short to avoid warnings. - long trunc1; - short trunc2; - - trunc1 = va_arg(ap, LONG); - trunc2 = (short)trunc1; - trunc1 = trunc2; - - TempInt = snprintf((LPSTR)BufferPtr, TempCount, TempBuff, trunc1); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short) n; - - TempInt = snprintf((LPSTR)BufferPtr, TempCount, TempBuff, s); - } - else - { - va_list apcopy; - va_copy(apcopy, ap); - TempInt = vsnprintf((LPSTR) BufferPtr, TempCount, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (TempInt == 0) - { - // The argument is "". - continue; - } - if (TempInt < 0 || static_cast<size_t>(TempInt) >= TempCount) /* buffer not long enough */ - { - TempNumberBuffer = (LPSTR) InternalMalloc(TempCount+1); - if (!TempNumberBuffer) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - errno = ENOMEM; - va_end(ap); - return -1; - } - - if (strncpy_s(TempNumberBuffer, TempCount+1, (LPSTR) BufferPtr, TempCount) != SAFECRT_SUCCESS) - { - ASSERT("strncpy_s failed!\n"); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - - mbtowcResult = MultiByteToWideChar(CP_ACP, 0, - TempNumberBuffer, - TempCount, - BufferPtr, TempCount); - if (!mbtowcResult) - { - ASSERT("MultiByteToWideChar failed. Error is %d\n", - GetLastError()); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - BufferPtr += TempCount; - BufferRanOut = TRUE; - } - else - { - TempNumberBuffer = (LPSTR) InternalMalloc(TempInt+1); - if (!TempNumberBuffer) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - - if (strncpy_s(TempNumberBuffer, TempInt+1, (LPSTR) BufferPtr, TempInt) != SAFECRT_SUCCESS) - { - ASSERT("strncpy_s failed!\n"); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - - mbtowcResult = MultiByteToWideChar(CP_ACP, 0, - TempNumberBuffer, - TempInt, - BufferPtr, TempInt); - if (!mbtowcResult) - { - ASSERT("MultiByteToWideChar failed. Error is %d\n", - GetLastError()); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - BufferPtr += TempInt; - } - free(TempNumberBuffer); - } - } - else - { - *BufferPtr++ = *Fmt++; /* copy regular chars into buffer */ - } - } - - if (static_cast<int>(Count) > (BufferPtr - Buffer)) //Count is assumed to be in the range of int - { - *BufferPtr = 0; /* end the string */ - } - - va_end(ap); - - if (BufferRanOut) - { - errno = ERANGE; - return -1; - } - else - { - return BufferPtr - Buffer; - } -} - int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list aparg) { CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */ diff --git a/src/pal/src/cruntime/silent_printf.cpp b/src/pal/src/cruntime/silent_printf.cpp index 1d10963973..4047c7e199 100644 --- a/src/pal/src/cruntime/silent_printf.cpp +++ b/src/pal/src/cruntime/silent_printf.cpp @@ -40,286 +40,6 @@ static INT Silent_AddPaddingVfprintf(PAL_FILE *stream, LPSTR In, INT Padding, static size_t Silent_PAL_wcslen(const wchar_16 *string); -/******************************************************************************* -Function: - PAL_vsnprintf (silent version) - for more details, see PAL_vsnprintf in printf.c -*******************************************************************************/ -INT Silent_PAL_vsnprintf(LPSTR Buffer, INT Count, LPCSTR Format, va_list aparg) -{ - BOOL BufferRanOut = FALSE; - CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */ - LPSTR BufferPtr = Buffer; - LPCSTR Fmt = Format; - LPWSTR TempWStr; - CHAR TempStr[MAX_STR_LEN+1]; - WCHAR TempWChar; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT Length; - INT TempInt; - int wctombResult; - va_list ap; - - va_copy(ap, aparg); - - while (*Fmt) - { - if ((BufferPtr - Buffer) >= Count) - { - BufferRanOut = TRUE; - break; - } - else if(*Fmt == '%' && - TRUE == Silent_ExtractFormatA(&Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_STRING) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWStr = va_arg(ap, LPWSTR); - Length = Silent_WideCharToMultiByte(TempWStr, -1, 0, 0); - if (!Length) - { - va_end(ap); - return -1; - } - - /* clip string output to MAX_STR_LEN characters */ - if (PRECISION_DOT == Precision) - { - Precision = MAX_STR_LEN; - } - - if (PRECISION_DOT == Precision) - { - /* copy nothing */ - *TempStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length - 1) - { - Length = Silent_WideCharToMultiByte(TempWStr, Precision, - TempStr, Length); - if (!Length) - { - va_end(ap); - return -1; - } - TempStr[Length] = 0; - Length = Precision; - } - /* copy everything */ - else - { - wctombResult = Silent_WideCharToMultiByte(TempWStr, -1, - TempStr, Length); - if (!wctombResult) - { - PAL_free(TempStr); - va_end(ap); - return -1; - } - --Length; /* exclude null char */ - } - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempStr, - Width - Length, - Flags); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - CHAR TempBuffer[4]; - - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar = va_arg(ap, int); - Length = Silent_WideCharToMultiByte(&TempWChar, 1, TempBuffer, 4); - if (!Length) - { - va_end(ap); - return -1; - } - TempBuffer[Length] = 0; - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempBuffer, - Width - Length, - Flags); - - } - /* this places the number of bytes written to the buffer in the - next arg */ - else if (Type == PFF_TYPE_N) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - if (Prefix == PFF_PREFIX_SHORT) - { - *(va_arg(ap, short *)) = BufferPtr - Buffer; - } - else - { - *(va_arg(ap, LPLONG)) = BufferPtr - Buffer; - } - } - else if (Type == PFF_TYPE_CHAR && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded chars, - // so we handle them here. - char ch[2]; - - ch[0] = (char) va_arg(ap, int); - ch[1] = '\0'; - Length = 1; - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - ch, - Width - Length, - Flags); - } - else if (Type == PFF_TYPE_STRING && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded strings, - // so we handle them here. - char *tempStr; - - tempStr = va_arg(ap, char *); - Length = strlen(tempStr); - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - tempStr, - Width - Length, - Flags); - } - /* types that sprintf can handle */ - else - { - size_t TempCount = Count - (BufferPtr - Buffer); - - TempInt = 0; - /* %h (short) doesn't seem to be handled properly by local sprintf, - so lets do the truncation ourselves. (ptr -> int -> short to avoid - warnings */ - if (Type == PFF_TYPE_P && Prefix == PFF_PREFIX_SHORT) - { - long trunc1; - short trunc2; - - trunc1 = va_arg(ap, LONG); - trunc2 = (short)trunc1; - - TempInt = snprintf(BufferPtr, TempCount, TempBuff, trunc2); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short) n; - - TempInt = snprintf(BufferPtr, TempCount, TempBuff, s); - } - else - { - /* limit string output (%s) to 300 characters */ - if(TempBuff[0] == '%' && TempBuff[1] == 's') - { - if (strcpy_s(TempBuff, sizeof(TempBuff), "%.300s") != SAFECRT_SUCCESS) - { - va_end(ap); - return -1; - } - } - va_list apcopy; - va_copy(apcopy, ap); - TempInt = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), BufferPtr, TempCount, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (TempInt < 0 || static_cast<size_t>(TempInt) >= TempCount) /* buffer not long enough */ - { - BufferPtr += TempCount; - BufferRanOut = TRUE; - } - else - { - BufferPtr += TempInt; - } - } - } - else - { - *BufferPtr++ = *Fmt++; /* copy regular chars into buffer */ - } - } - - if (Count > (BufferPtr - Buffer)) - { - *BufferPtr = 0; /* end the string */ - } - - va_end(ap); - - if (BufferRanOut) - { - return -1; - } - else - { - return BufferPtr - Buffer; - } -} - /*++ Function: PAL_vfprintf (silent version) diff --git a/src/pal/src/cruntime/string.cpp b/src/pal/src/cruntime/string.cpp index abe6d136f0..2abce6fd8f 100644 --- a/src/pal/src/cruntime/string.cpp +++ b/src/pal/src/cruntime/string.cpp @@ -278,7 +278,7 @@ PAL_atol(const char *szNumber) PERF_ENTRY(atol); ENTRY("atol (szNumber=%p (%s))\n", - szNumber?szNumber:"NULL" + szNumber, szNumber?szNumber:"NULL" ); lResult = atol(szNumber); diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h index f7856be902..8e1a5f158b 100644 --- a/src/pal/src/include/pal/palinternal.h +++ b/src/pal/src/include/pal/palinternal.h @@ -502,7 +502,6 @@ function_name() to call the system's implementation #undef vfwprintf #undef vprintf #undef wprintf -#undef swprintf #undef wcstod #undef wcstol #undef wcstoul @@ -525,10 +524,6 @@ function_name() to call the system's implementation #undef iswspace #undef towlower #undef towupper -#undef vsprintf -#undef vswprintf -#undef _vsnprintf -#undef vsnprintf #undef wvsnprintf #ifdef _AMD64_ diff --git a/src/pal/src/include/pal/printfcpp.hpp b/src/pal/src/include/pal/printfcpp.hpp index 0a728c9fd7..12e923a506 100644 --- a/src/pal/src/include/pal/printfcpp.hpp +++ b/src/pal/src/include/pal/printfcpp.hpp @@ -32,22 +32,6 @@ typedef char16_t wchar_16; // __wchar_16_cpp (which is defined in palinternal.h) extern "C" { int - __cdecl - PAL__vsnprintf( - LPSTR Buffer, - size_t Count, - LPCSTR Format, - va_list ap); - - int - __cdecl - PAL__wvsnprintf( - LPWSTR Buffer, - size_t Count, - LPCWSTR Format, - va_list ap); - - int __cdecl PAL_vfprintf( PAL_FILE *stream, @@ -71,48 +55,9 @@ namespace CorUnix const char *format, va_list ap); - int - InternalWvsnprintf( - CPalThread *pthrCurrent, - LPWSTR Buffer, - size_t Count, - LPCWSTR Format, - va_list ap); - - int - InternalVsnprintf( - CPalThread *pthrCurrent, - LPSTR Buffer, - size_t Count, - LPCSTR Format, - va_list ap); - - int - InternalVfwprintf( - CPalThread *pthrCurrent, - PAL_FILE *stream, - const wchar_16 *format, - va_list ap); - } #else // __cplusplus - int - __cdecl - PAL__vsnprintf( - LPSTR Buffer, - size_t Count, - LPCSTR Format, - va_list ap); - - int - __cdecl - PAL__wvsnprintf( - LPWSTR Buffer, - size_t Count, - LPCWSTR Format, - va_list ap); - int __cdecl PAL_vfprintf( diff --git a/src/pal/src/misc/dbgmsg.cpp b/src/pal/src/misc/dbgmsg.cpp index 488e61494e..d6f173f160 100644 --- a/src/pal/src/misc/dbgmsg.cpp +++ b/src/pal/src/misc/dbgmsg.cpp @@ -528,8 +528,8 @@ int DBG_printf_gcc(DBG_CHANNEL_ID channel, DBG_LEVEL_ID level, BOOL bHeader, va_start(args, format); - output_size+=Silent_PAL_vsnprintf(buffer_ptr, DBG_BUFFER_SIZE-output_size, - format, args); + output_size+=_vsnprintf_s(buffer_ptr, DBG_BUFFER_SIZE-output_size, _TRUNCATE, + format, args); va_end(args); if( output_size > DBG_BUFFER_SIZE ) @@ -633,8 +633,8 @@ int DBG_printf_c99(DBG_CHANNEL_ID channel, DBG_LEVEL_ID level, BOOL bHeader, } va_start(args, format); - output_size+=Silent_PAL_vsnprintf(buffer_ptr, DBG_BUFFER_SIZE-output_size, - format, args); + output_size+=_vsnprintf_s(buffer_ptr, DBG_BUFFER_SIZE-output_size, _TRUNCATE, + format, args); va_end(args); if(output_size>DBG_BUFFER_SIZE) @@ -960,7 +960,7 @@ void PAL_DisplayDialogFormatted(const char *szTitle, const char *szTextFormat, . const int cchBuffer = 4096; char *szBuffer = (char*)alloca(cchBuffer); - PAL__vsnprintf(szBuffer, cchBuffer, szTextFormat, args); + _vsnprintf_s(szBuffer, cchBuffer, _TRUNCATE, szTextFormat, args); PAL_DisplayDialog(szTitle, szBuffer); va_end(args); diff --git a/src/pal/src/misc/fmtmessage.cpp b/src/pal/src/misc/fmtmessage.cpp index 46e0af6e0d..70b854aa9c 100644 --- a/src/pal/src/misc/fmtmessage.cpp +++ b/src/pal/src/misc/fmtmessage.cpp @@ -205,7 +205,7 @@ static LPWSTR FMTMSG_ProcessPrintf( wchar_t c , UINT nFormatLength = 0; int nBufferLength = 0; - TRACE( "FMTMSG_ProcessPrintf( %C, %S, %S )\n", c, + TRACE( "FMTMSG_ProcessPrintf( %C, %S, %p )\n", c, lpPrintfString, lpInsertString ); switch ( c ) @@ -299,7 +299,6 @@ FormatMessageW( LPWSTR lpReturnString = NULL; LPWSTR lpWorkingString = NULL; - PERF_ENTRY(FormatMessageW); ENTRY( "FormatMessageW(dwFlags=%#x, lpSource=%p, dwMessageId=%#x, " "dwLanguageId=%#x, lpBuffer=%p, nSize=%u, va_list=%p)\n", diff --git a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt index cf062530eb..8225ed2dd4 100644 --- a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt @@ -165,7 +165,7 @@ add_subdirectory(_snwprintf_s) add_subdirectory(_stricmp) add_subdirectory(_strlwr) add_subdirectory(_strnicmp) -add_subdirectory(_vsnprintf) +add_subdirectory(_vsnprintf_s) add_subdirectory(_vsnwprintf_s) add_subdirectory(_wcsicmp) add_subdirectory(_wcslwr) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt deleted file mode 100644 index 92540541f3..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vsnprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test5 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp deleted file mode 100644 index 534e42e293..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Test #5 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include <palsuite.h> -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -static void DoTest(char *formatstr, int param, char *checkstr) -{ - char buf[256] = { 0 }; - int n = -1; - - Testvsnprintf(buf, 256, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -static void DoShortTest(char *formatstr, int param, char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - Testvsnprintf(buf, 256, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoTest("foo %n bar", 4, "foo bar"); - DoTest("foo %#n bar", 4, "foo bar"); - DoTest("foo % n bar", 4, "foo bar"); - DoTest("foo %+n bar", 4, "foo bar"); - DoTest("foo %-n bar", 4, "foo bar"); - DoTest("foo %0n bar", 4, "foo bar"); - DoShortTest("foo %hn bar", 4, "foo bar"); - DoTest("foo %ln bar", 4, "foo bar"); - DoTest("foo %Ln bar", 4, "foo bar"); - DoTest("foo %I64n bar", 4, "foo bar"); - DoTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat deleted file mode 100644 index c3848824f1..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with the count specifier. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h index 30e70648c3..7c81136f71 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h @@ -4,7 +4,7 @@ /*============================================================================ ** -** Source: _vsnprintf.h +** Source: _vsnprintf_s.h ** ** Purpose: Contains common testing functions for _vsnprintf ** @@ -21,7 +21,7 @@ int Testvsnprintf(char* buf, size_t count, const char* format, ...) va_list arglist; va_start(arglist, format); - retVal = _vsnprintf(buf, count, format, arglist); + retVal = _vsnprintf_s(buf, count, _TRUNCATE, format, arglist); va_end(arglist); return (retVal); diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt index 489b7bf566..489b7bf566 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp index 88aeec27a5..db70f5612b 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. @@ -45,11 +45,11 @@ int __cdecl main(int argc, char *argv[]) { Fail("ERROR: expected negative return value, got %d", ret); } - if (memcmp(checkstr, buf, 8) != 0 || buf[8] != 'x') + if (memcmp(checkstr, buf, 7) != 0 || buf[7] != 0) { Fail("ERROR: expected %s (up to %d chars), got %s\n", checkstr, 8, buf); } - + PAL_Terminate(); return PASS; } diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat index f96bf084f2..f96bf084f2 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt index bc35dbd0c2..bc35dbd0c2 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp index 3099957ab7..707a91c048 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/test10.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat index a3d8eca54e..a3d8eca54e 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt index bf3dd9a534..bf3dd9a534 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp index 74b0435c6d..4c710e56b0 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/test11.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat index 17e9f04946..17e9f04946 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt index 9fceeaf7a5..9fceeaf7a5 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp index 3718620971..528e6582a8 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat index 82f58e4371..82f58e4371 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt index 7e805f6ad4..7e805f6ad4 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp index 1abada4033..645a118682 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat index d308edf871..d308edf871 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt index 6e4566b577..6e4566b577 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp index 2e98f6ad4e..05965f0ed7 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat index 8d11b1d6ff..8d11b1d6ff 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt index d9039b39b7..d9039b39b7 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp index 4d32e9c638..cd34f74e6c 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat index 913912508e..913912508e 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt index b298df318b..b298df318b 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp index 118ba1453c..de9b74f9b3 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat index fc2f13071b..fc2f13071b 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt index b195f334d3..b195f334d3 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp index 9b5063ddf0..3304eda7f9 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/test17.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat index aeb924495c..aeb924495c 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt index f0f6d1124e..f0f6d1124e 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp index 5232befc7f..14ad8f583a 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/test18.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat index 57aaed5953..57aaed5953 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt index 44b38902ef..44b38902ef 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp index 211354bc3a..6f2aefa94c 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat index cda8966865..cda8966865 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt index 1d3910e70c..1d3910e70c 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp index 4bac4d2c83..69c8c2723b 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. */ diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat index 6e8f03e639..6e8f03e639 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt index 62d765ec5f..62d765ec5f 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp index 2b30c9ad99..a244aa44b6 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat index 638cef69ef..638cef69ef 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt index 5662bd57ad..5662bd57ad 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp index 33fc49deba..0cf25cb88d 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat index 03ff2931bc..03ff2931bc 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt index d80d433c22..d80d433c22 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp index 103d1181c2..cbcead88b5 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat index e375f9238d..e375f9238d 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt index a1dc0a7c2c..a1dc0a7c2c 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp index c7e45d67fa..4843d27598 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. */ diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat index 09eb481b59..09eb481b59 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt index 1ca4732492..1ca4732492 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp index 2cefbeac25..8021a797c8 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat index 1bdf411983..1bdf411983 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt index 583971fe5a..583971fe5a 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp index d2cd8165c0..d36846e401 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.cpp +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp @@ -12,7 +12,7 @@ **===================================================================*/ #include <palsuite.h> -#include "../_vsnprintf.h" +#include "../_vsnprintf_s.h" /* * Notes: memcmp is used, as is strlen. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat index bdaae87ce8..bdaae87ce8 100644 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h b/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h index 6f4c914a82..210b12ec7a 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h +++ b/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h @@ -18,7 +18,7 @@ void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) { @@ -33,7 +33,7 @@ void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) { @@ -48,7 +48,7 @@ void DoPointerTest(const WCHAR *formatstr, void* param, const WCHAR *checkstr1) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) { Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" @@ -57,51 +57,11 @@ void DoPointerTest(const WCHAR *formatstr, void* param, const WCHAR *checkstr1) } } -void DoCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - WCHAR buf[512] = { 0 }; - int n = -1; - - swprintf(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -void DoShortCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - short int n = -1; - - swprintf(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -114,7 +74,7 @@ void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -127,7 +87,7 @@ void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, value); + swprintf_s(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(checkstr)* 2 + 2) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -141,7 +101,7 @@ void DoI64Test(const WCHAR *formatstr, INT64 param, char *paramdesc, { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -155,7 +115,7 @@ void DoDoubleTest(const WCHAR *formatstr, double value, const WCHAR *checkstr1, { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, value); + swprintf_s(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2)*2 + 2) != 0) { @@ -171,7 +131,7 @@ void DoArgumentPrecTest(const WCHAR *formatstr, int precision, void *param, { WCHAR buf[256]; - swprintf(buf, formatstr, precision, param); + swprintf_s(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { @@ -187,7 +147,7 @@ void DoArgumentPrecDoubleTest(const WCHAR *formatstr, int precision, double para { WCHAR buf[256]; - swprintf(buf, formatstr, precision, param); + swprintf_s(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp index 626040d9f7..c47d7d5202 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp @@ -31,7 +31,7 @@ int __cdecl main(int argc, char *argv[]) } checkstr = convert("hello world"); - swprintf(buf, convert("hello world")); + swprintf_s(buf, _countof(buf), convert("hello world")); if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp index c0346036cd..0967bc8f4b 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp @@ -33,14 +33,6 @@ int __cdecl main(int argc, char *argv[]) convert("ba"), convert("ba")); DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar", convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*n"), 3, (void*)&n, "pointer to int", convert(""), - convert("")); - if (n != 0) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 0, n); - } - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", convert("a"), convert("a")); DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", convert("a"), diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt deleted file mode 100644 index 967ccbb992..0000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_swprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test5 coreclrpal) - -target_link_libraries(paltest_swprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp deleted file mode 100644 index e85adc120e..0000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose:Tests swprintf with the count specifier -** -** -**==========================================================================*/ - - - -#include <palsuite.h> -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *longStr; - WCHAR *longResult; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - longStr = - convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"); - longResult = - convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - " bar"); - - DoCountTest(convert("foo %n bar"), 4, convert("foo bar")); - DoCountTest(longStr, 257, longResult); - DoCountTest(convert("fo%n bar"), 2, convert("fo bar")); - DoCountTest(convert("%n"), 0, convert("")); - DoCountTest(convert("foo %#n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo % n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %+n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %-n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %0n bar"), 4, convert("foo bar")); - DoShortCountTest(convert("foo %hn bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %ln bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %Ln bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %I64n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %20.3n bar"), 4, convert("foo bar")); - - PAL_Terminate(); - - free(longStr); - free(longResult); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat deleted file mode 100644 index ef1f1ffc5a..0000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests swprintf with the count specifier diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp index 2007fefc5b..18c8c0ea1a 100644 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp @@ -29,7 +29,7 @@ int __cdecl main(int argc, char *argv[]) return(FAIL); } - testvsp(buf, "hello world"); + testvsp(buf, _countof(buf), "hello world"); if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) { @@ -37,8 +37,8 @@ int __cdecl main(int argc, char *argv[]) checkstr, 256, buf); } - testvsp(buf, "xxxxxxxxxxxxxxxxx"); - ret = testvsp(buf, "hello world"); + testvsp(buf, _countof(buf), "xxxxxxxxxxxxxxxxx"); + ret = testvsp(buf, _countof(buf), "hello world"); if (ret != strlen(checkstr)) { diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt deleted file mode 100644 index 6d14bf76bf..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vsprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test5 coreclrpal) - -target_link_libraries(paltest_vsprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp deleted file mode 100644 index e630d8863b..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Test #5 for the vsprintf function. -** -** -**===================================================================*/ - -#include <palsuite.h> -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoTest("foo %n bar", 4, "foo bar"); - DoTest("foo %#n bar", 4, "foo bar"); - DoTest("foo % n bar", 4, "foo bar"); - DoTest("foo %+n bar", 4, "foo bar"); - DoTest("foo %-n bar", 4, "foo bar"); - DoTest("foo %0n bar", 4, "foo bar"); - DoShortTest("foo %hn bar", 4, "foo bar"); - DoTest("foo %ln bar", 4, "foo bar"); - DoTest("foo %Ln bar", 4, "foo bar"); - DoTest("foo %I64n bar", 4, "foo bar"); - DoTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat deleted file mode 100644 index 81748f88b9..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with the count specifier. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h b/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h index 7b04a777ca..22bf53e53b 100644 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h +++ b/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h @@ -14,13 +14,13 @@ #define __VSPRINTF_H__ /* These functions leaks memory like crazy. C'est la vie. */ -int testvsp(char* buf, const char* format, ...) +int testvsp(char* buf, size_t buffSize, const char* format, ...) { int retVal; va_list arglist; va_start(arglist, format); - retVal = vsprintf(buf, format, arglist); + retVal = _vsnprintf_s(buf, buffSize, _TRUNCATE, format, arglist); va_end(arglist); return (retVal); @@ -30,7 +30,7 @@ void DoStrTest(const char *formatstr, char* param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" @@ -43,7 +43,7 @@ void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" @@ -57,7 +57,7 @@ void DoCharTest(const char *formatstr, char param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -70,7 +70,7 @@ void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -83,7 +83,7 @@ void DoNumTest(const char *formatstr, int value, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -96,7 +96,7 @@ void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *c { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -109,7 +109,7 @@ void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, ch { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -124,7 +124,7 @@ void DoArgumentPrecTest(const char *formatstr, int precision, void *param, { char buf[256]; - testvsp(buf, formatstr, precision, param); + testvsp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -140,7 +140,7 @@ void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param { char buf[256]; - testvsp(buf, formatstr, precision, param); + testvsp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -155,7 +155,7 @@ void DoPointerTest(const char *formatstr, void* param, char* paramstr, { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1)) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -169,7 +169,7 @@ void DoI64DoubleTest(const char *formatstr, INT64 value, char *valuestr, { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -183,7 +183,7 @@ void DoTest(const char *formatstr, int param, const char *checkstr) char buf[256] = { 0 }; int n = -1; - testvsp(buf, formatstr, &n); + testvsp(buf, _countof(buf), formatstr, &n); if (n != param) { @@ -201,7 +201,7 @@ void DoShortTest(const char *formatstr, int param, const char *checkstr) char buf[256] = { 0 }; short int n = -1; - testvsp(buf, formatstr, &n); + testvsp(buf, _countof(buf), formatstr, &n); if (n != param) { diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp index d386ce104f..968f8a5c69 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp @@ -27,7 +27,7 @@ int __cdecl main(int argc, char *argv[]) return(FAIL); checkstr = convert("hello world"); - testvswp(buf, checkstr); + testvswp(buf, _countof(buf), checkstr); if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp index 1d1c5656b2..12f2b7ba99 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp @@ -24,7 +24,7 @@ void DoArgumentPrecTest(WCHAR *formatstr, int precision, void *param, { WCHAR buf[256]; - testvswp(buf, formatstr, precision, param); + testvswp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { @@ -43,7 +43,7 @@ void DoArgumentPrecDoubleTest(WCHAR *formatstr, int precision, double param, { WCHAR buf[256]; - testvswp(buf, formatstr, precision, param); + testvswp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp index 5c9047b5a7..583cf0c849 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp @@ -21,7 +21,7 @@ static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr, { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) { @@ -39,7 +39,7 @@ static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr, { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt deleted file mode 100644 index 888ce27d22..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vswprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test5 coreclrpal) - -target_link_libraries(paltest_vswprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp deleted file mode 100644 index 42146c8be7..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Test #5 for the vswprintf function. -** -** -**===================================================================*/ - -#include <palsuite.h> -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -static void DoTest(WCHAR *formatstr, int param, WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - int n = -1; - - testvswp(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -static void DoShortTest(WCHAR *formatstr, int param, WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - short int n = -1; - - testvswp(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoTest(convert("foo %n bar"), 4, convert("foo bar")); - DoTest(convert("foo %#n bar"), 4, convert("foo bar")); - DoTest(convert("foo % n bar"), 4, convert("foo bar")); - DoTest(convert("foo %+n bar"), 4, convert("foo bar")); - DoTest(convert("foo %-n bar"), 4, convert("foo bar")); - DoTest(convert("foo %0n bar"), 4, convert("foo bar")); - DoShortTest(convert("foo %hn bar"), 4, convert("foo bar")); - DoTest(convert("foo %ln bar"), 4, convert("foo bar")); - DoTest(convert("foo %Ln bar"), 4, convert("foo bar")); - DoTest(convert("foo %I64n bar"), 4, convert("foo bar")); - DoTest(convert("foo %20.3n bar"), 4, convert("foo bar")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat deleted file mode 100644 index 17ca0fd33b..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with the count specifier. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h b/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h index 37a379212e..36895d207f 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h @@ -15,13 +15,13 @@ #define __vswprintf_H__ /* These functions leaks memory like crazy. C'est la vie. */ -int testvswp(wchar_t* buf, const wchar_t* format, ...) +int testvswp(wchar_t* buf, size_t buffSize, const wchar_t* format, ...) { int retVal = 0; va_list arglist; va_start(arglist, format); - retVal = vswprintf(buf, format, arglist); + retVal = _vsnwprintf_s(buf, buffSize, _TRUNCATE, format, arglist); va_end(arglist); return( retVal); @@ -31,7 +31,7 @@ void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) { @@ -46,7 +46,7 @@ void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) { @@ -61,7 +61,7 @@ void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -75,7 +75,7 @@ void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -89,7 +89,7 @@ void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -102,7 +102,7 @@ void DoI64NumTest(const WCHAR *formatstr, INT64 value, char *valuestr, const WCH { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -115,7 +115,7 @@ void DoDoubleTest(const WCHAR *formatstr, double value, const WCHAR *checkstr1, { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp index 43cda8f447..ebc4d25bcb 100644 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp +++ b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp @@ -104,7 +104,7 @@ int __cdecl main(int argc, char *argv[]) } // now verify that it only used the first 3 characters of the prefix - swprintf(wTempString, convert("%s\\%s"), wPath, wPrefix); + swprintf_s(wTempString, _countof(wTempString), convert("%s\\%s"), wPath, wPrefix); if (memcmp(wTempString, wReturnedName, wcslen(wTempString)*sizeof(WCHAR)) == 0) { free (wPath); diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt index 2cedca2b97..98b17fa6f9 100644 --- a/src/pal/tests/palsuite/paltestlist.txt +++ b/src/pal/tests/palsuite/paltestlist.txt @@ -210,7 +210,6 @@ c_runtime/swprintf/test18/paltest_swprintf_test18 c_runtime/swprintf/test19/paltest_swprintf_test19 c_runtime/swprintf/test3/paltest_swprintf_test3 c_runtime/swprintf/test4/paltest_swprintf_test4 -c_runtime/swprintf/test5/paltest_swprintf_test5 c_runtime/swprintf/test6/paltest_swprintf_test6 c_runtime/swprintf/test8/paltest_swprintf_test8 c_runtime/swprintf/test9/paltest_swprintf_test9 @@ -292,7 +291,6 @@ c_runtime/vsprintf/test19/paltest_vsprintf_test19 c_runtime/vsprintf/test2/paltest_vsprintf_test2 c_runtime/vsprintf/test3/paltest_vsprintf_test3 c_runtime/vsprintf/test4/paltest_vsprintf_test4 -c_runtime/vsprintf/test5/paltest_vsprintf_test5 c_runtime/vsprintf/test6/paltest_vsprintf_test6 c_runtime/vsprintf/test7/paltest_vsprintf_test7 c_runtime/vsprintf/test8/paltest_vsprintf_test8 @@ -310,7 +308,6 @@ c_runtime/vswprintf/test18/paltest_vswprintf_test18 c_runtime/vswprintf/test19/paltest_vswprintf_test19 c_runtime/vswprintf/test3/paltest_vswprintf_test3 c_runtime/vswprintf/test4/paltest_vswprintf_test4 -c_runtime/vswprintf/test5/paltest_vswprintf_test5 c_runtime/vswprintf/test6/paltest_vswprintf_test6 c_runtime/vswprintf/test8/paltest_vswprintf_test8 c_runtime/vswprintf/test9/paltest_vswprintf_test9 @@ -398,25 +395,24 @@ c_runtime/_snwprintf_s/test9/paltest_snwprintf_test9 c_runtime/_stricmp/test1/paltest_stricmp_test1 c_runtime/_strlwr/test1/paltest_strlwr_test1 c_runtime/_strnicmp/test1/paltest_strnicmp_test1 -c_runtime/_vsnprintf/test1/paltest_vsnprintf_test1 -c_runtime/_vsnprintf/test10/paltest_vsnprintf_test10 -c_runtime/_vsnprintf/test11/paltest_vsnprintf_test11 -c_runtime/_vsnprintf/test12/paltest_vsnprintf_test12 -c_runtime/_vsnprintf/test13/paltest_vsnprintf_test13 -c_runtime/_vsnprintf/test14/paltest_vsnprintf_test14 -c_runtime/_vsnprintf/test15/paltest_vsnprintf_test15 -c_runtime/_vsnprintf/test16/paltest_vsnprintf_test16 -c_runtime/_vsnprintf/test17/paltest_vsnprintf_test17 -c_runtime/_vsnprintf/test18/paltest_vsnprintf_test18 -c_runtime/_vsnprintf/test19/paltest_vsnprintf_test19 -c_runtime/_vsnprintf/test2/paltest_vsnprintf_test2 -c_runtime/_vsnprintf/test3/paltest_vsnprintf_test3 -c_runtime/_vsnprintf/test4/paltest_vsnprintf_test4 -c_runtime/_vsnprintf/test5/paltest_vsnprintf_test5 -c_runtime/_vsnprintf/test6/paltest_vsnprintf_test6 -c_runtime/_vsnprintf/test7/paltest_vsnprintf_test7 -c_runtime/_vsnprintf/test8/paltest_vsnprintf_test8 -c_runtime/_vsnprintf/test9/paltest_vsnprintf_test9 +c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 +c_runtime/_vsnprintf_s/test10/paltest_vsnprintf_test10 +c_runtime/_vsnprintf_s/test11/paltest_vsnprintf_test11 +c_runtime/_vsnprintf_s/test12/paltest_vsnprintf_test12 +c_runtime/_vsnprintf_s/test13/paltest_vsnprintf_test13 +c_runtime/_vsnprintf_s/test14/paltest_vsnprintf_test14 +c_runtime/_vsnprintf_s/test15/paltest_vsnprintf_test15 +c_runtime/_vsnprintf_s/test16/paltest_vsnprintf_test16 +c_runtime/_vsnprintf_s/test17/paltest_vsnprintf_test17 +c_runtime/_vsnprintf_s/test18/paltest_vsnprintf_test18 +c_runtime/_vsnprintf_s/test19/paltest_vsnprintf_test19 +c_runtime/_vsnprintf_s/test2/paltest_vsnprintf_test2 +c_runtime/_vsnprintf_s/test3/paltest_vsnprintf_test3 +c_runtime/_vsnprintf_s/test4/paltest_vsnprintf_test4 +c_runtime/_vsnprintf_s/test6/paltest_vsnprintf_test6 +c_runtime/_vsnprintf_s/test7/paltest_vsnprintf_test7 +c_runtime/_vsnprintf_s/test8/paltest_vsnprintf_test8 +c_runtime/_vsnprintf_s/test9/paltest_vsnprintf_test9 c_runtime/_vsnwprintf_s/test1/paltest_vsnwprintf_test1 c_runtime/_vsnwprintf_s/test10/paltest_vsnwprintf_test10 c_runtime/_vsnwprintf_s/test11/paltest_vsnwprintf_test11 diff --git a/src/pal/tests/palsuite/palverify.dat b/src/pal/tests/palsuite/palverify.dat index d6e113b670..1872313a94 100644 --- a/src/pal/tests/palsuite/palverify.dat +++ b/src/pal/tests/palsuite/palverify.dat @@ -66,25 +66,24 @@ c_runtime/_snwprintf_s/test19,1 c_runtime/_stricmp/test1,1 c_runtime/_strlwr/test1,1 c_runtime/_strnicmp/test1,1 -c_runtime/_vsnprintf/test1,1 -c_runtime/_vsnprintf/test2,1 -c_runtime/_vsnprintf/test3,1 -c_runtime/_vsnprintf/test4,1 -c_runtime/_vsnprintf/test5,1 -c_runtime/_vsnprintf/test6,1 -c_runtime/_vsnprintf/test7,1 -c_runtime/_vsnprintf/test8,1 -c_runtime/_vsnprintf/test9,1 -c_runtime/_vsnprintf/test10,1 -c_runtime/_vsnprintf/test11,1 -c_runtime/_vsnprintf/test12,1 -c_runtime/_vsnprintf/test13,1 -c_runtime/_vsnprintf/test14,1 -c_runtime/_vsnprintf/test15,1 -c_runtime/_vsnprintf/test16,1 -c_runtime/_vsnprintf/test17,1 -c_runtime/_vsnprintf/test18,1 -c_runtime/_vsnprintf/test19,1 +c_runtime/_vsnprintf_s/test1,1 +c_runtime/_vsnprintf_s/test2,1 +c_runtime/_vsnprintf_s/test3,1 +c_runtime/_vsnprintf_s/test4,1 +c_runtime/_vsnprintf_s/test6,1 +c_runtime/_vsnprintf_s/test7,1 +c_runtime/_vsnprintf_s/test8,1 +c_runtime/_vsnprintf_s/test9,1 +c_runtime/_vsnprintf_s/test10,1 +c_runtime/_vsnprintf_s/test11,1 +c_runtime/_vsnprintf_s/test12,1 +c_runtime/_vsnprintf_s/test13,1 +c_runtime/_vsnprintf_s/test14,1 +c_runtime/_vsnprintf_s/test15,1 +c_runtime/_vsnprintf_s/test16,1 +c_runtime/_vsnprintf_s/test17,1 +c_runtime/_vsnprintf_s/test18,1 +c_runtime/_vsnprintf_s/test19,1 c_runtime/_vsnwprintf_s/test1,1 c_runtime/_vsnwprintf_s/test2,1 c_runtime/_vsnwprintf_s/test3,1 diff --git a/src/palrt/coguid.cpp b/src/palrt/coguid.cpp index cd03dce591..6c1efd460a 100644 --- a/src/palrt/coguid.cpp +++ b/src/palrt/coguid.cpp @@ -17,7 +17,7 @@ STDAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lptsz, int cchMax) if (cchMax < 39) return 0; - return swprintf(lptsz, W("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), + return swprintf_s(lptsz, cchMax, W("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), rguid.Data1, rguid.Data2, rguid.Data3, rguid.Data4[0], rguid.Data4[1], rguid.Data4[2], rguid.Data4[3], diff --git a/src/utilcode/log.cpp b/src/utilcode/log.cpp index 0dc85527c0..c07ac8baff 100644 --- a/src/utilcode/log.cpp +++ b/src/utilcode/log.cpp @@ -325,7 +325,7 @@ VOID LogSpewAlwaysValist(const char *fmt, va_list args) needsPrefix = (fmt[strlen(fmt)-1] == '\n'); - int cCountWritten = _vsnprintf(&pBuffer[buflen], BUFFERSIZE-buflen, fmt, args ); + int cCountWritten = _vsnprintf_s(&pBuffer[buflen], BUFFERSIZE-buflen, _TRUNCATE, fmt, args ); pBuffer[BUFFERSIZE-1] = 0; if (cCountWritten < 0) { buflen = BUFFERSIZE - 1; diff --git a/src/utilcode/sstring.cpp b/src/utilcode/sstring.cpp index ce532d70f6..7c332e08c3 100644 --- a/src/utilcode/sstring.cpp +++ b/src/utilcode/sstring.cpp @@ -2107,7 +2107,7 @@ void SString::VPrintf(const CHAR *format, va_list args) else if (errno!=0 && errno!=EBADF && errno!=ERANGE) { - CONSISTENCY_CHECK_MSG(FALSE, "_vsnprintf failed. Potential globalization bug."); + CONSISTENCY_CHECK_MSG(FALSE, "_vsnprintf_s failed. Potential globalization bug."); ThrowHR(HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION)); } } diff --git a/src/vm/multicorejit.cpp b/src/vm/multicorejit.cpp index 24154a81c7..7660fd1895 100644 --- a/src/vm/multicorejit.cpp +++ b/src/vm/multicorejit.cpp @@ -168,7 +168,7 @@ void _MulticoreJitTrace(const char * format, ...) int len; len = sprintf_s(buffer, _countof(buffer), "Mcj TID %04x: ", GetCurrentThreadId()); - len += _vsnprintf(buffer + len, _countof(buffer) - len, format, args); + len += _vsnprintf_s(buffer + len, _countof(buffer) - len, format, args); len += sprintf_s(buffer + len, _countof(buffer) - len, ", (time=%d ms)\r\n", GetTickCount() - s_startTick); OutputDebugStringA(buffer); |