Remove all usage of vsnprintf (#8709)
authorJan Vorlicek <janvorli@microsoft.com>
Fri, 23 Dec 2016 13:41:28 +0000 (14:41 +0100)
committerJan Kotas <jkotas@microsoft.com>
Fri, 23 Dec 2016 13:41:28 +0000 (05:41 -0800)
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:
src/ToolBox/SOS/Strike/strike.h
src/ToolBox/SOS/Strike/xplat/dbgeng.h
src/dlls/mscordac/mscordac_unixexports.src
src/gc/env/gcenv.base.h
src/gc/gc.cpp
src/md/compiler/regmeta.cpp
src/pal/inc/pal.h
src/pal/inc/rt/palrt.h
src/pal/inc/rt/safecrt.h
src/pal/src/cruntime/printf.cpp
src/pal/src/cruntime/printfcpp.cpp
src/pal/src/cruntime/silent_printf.cpp
src/pal/src/cruntime/string.cpp
src/pal/src/include/pal/palinternal.h
src/pal/src/include/pal/printfcpp.hpp
src/pal/src/misc/dbgmsg.cpp
src/pal/src/misc/fmtmessage.cpp
src/pal/tests/palsuite/c_runtime/CMakeLists.txt
src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp [deleted file]
src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat [deleted file]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt with 95% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp with 93% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/test10.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/test11.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/test17.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/test18.cpp with 98% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp with 99% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp with 99% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt with 100% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.cpp with 97% similarity]
src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat [moved from src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat with 100% similarity]
src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt
src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h
src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp
src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp
src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp [deleted file]
src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat [deleted file]
src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt
src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp
src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp [deleted file]
src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat [deleted file]
src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h
src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt
src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp
src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp
src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp
src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp [deleted file]
src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat [deleted file]
src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h
src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp
src/pal/tests/palsuite/paltestlist.txt
src/pal/tests/palsuite/palverify.dat
src/palrt/coguid.cpp
src/utilcode/log.cpp
src/utilcode/sstring.cpp
src/vm/multicorejit.cpp

index e070898..dfc0dcf 100644 (file)
 #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_)
 
index b456227..5dcf957 100644 (file)
@@ -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);
index 7d60c1e..ab73c4f 100644 (file)
@@ -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
index 94f7376..0a0de73 100644 (file)
@@ -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
index 6187938..586da23 100644 (file)
@@ -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;
index 230d1e4..feb1cdd 100644 (file)
@@ -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());
index 05c777c..51ac5b9 100644 (file)
@@ -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);
index c181f38..ce637ba 100644 (file)
@@ -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);
index 3cc10ce..ab3e37e 100644 (file)
@@ -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>
index c437b8e..72c7e11 100644 (file)
@@ -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:
index ea074a6..85ec698 100644 (file)
@@ -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 */
index 1d10963..4047c7e 100644 (file)
@@ -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)
index abe6d13..2abce6f 100644 (file)
@@ -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);
index f7856be..8e1a5f1 100644 (file)
@@ -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_ 
index 0a728c9..12e923a 100644 (file)
@@ -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(
index 488e614..d6f173f 100644 (file)
@@ -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);
index 46e0af6..70b854a 100644 (file)
@@ -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", 
index cf06253..8225ed2 100644 (file)
@@ -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 (file)
index 9254054..0000000
+++ /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 (file)
index 534e42e..0000000
+++ /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 (file)
index c384882..0000000
+++ /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.
@@ -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)
@@ -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);
@@ -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;
 }
@@ -12,7 +12,7 @@
 **===================================================================*/ 
  
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/ 
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/  
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/   
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/   
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/   
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/ 
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/ 
  
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 /*
  * Notes: memcmp is used, as is strlen.
  */
@@ -12,7 +12,7 @@
 **===================================================================*/ 
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
     
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 /*
  * Notes: memcmp is used, as is strlen.
  */
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
@@ -12,7 +12,7 @@
 **===================================================================*/
 
 #include <palsuite.h>
-#include "../_vsnprintf.h"
+#include "../_vsnprintf_s.h"
 
 /*
  * Notes: memcmp is used, as is strlen.
index cafb953..8fe1cb6 100644 (file)
@@ -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)
index 6f4c914..210b12e 100644 (file)
@@ -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)
     {
index 626040d..c47d7d5 100644 (file)
@@ -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)
     {
index c034603..0967bc8 100644 (file)
@@ -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 (file)
index 967ccbb..0000000
+++ /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 (file)
index e85adc1..0000000
+++ /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 (file)
index ef1f1ff..0000000
+++ /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
index cafb953..8fe1cb6 100644 (file)
@@ -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)
index 2007fef..18c8c0e 100644 (file)
@@ -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 (file)
index 6d14bf7..0000000
+++ /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 (file)
index e630d88..0000000
+++ /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 (file)
index 81748f8..0000000
+++ /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.
index 7b04a77..22bf53e 100644 (file)
 #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)
     {
index cafb953..8fe1cb6 100644 (file)
@@ -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)
index d386ce1..968f8a5 100644 (file)
@@ -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)
     {
index 1d1c565..12f2b7b 100644 (file)
@@ -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)
     {
index 5c9047b..583cf0c 100644 (file)
@@ -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 (file)
index 888ce27..0000000
+++ /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 (file)
index 42146c8..0000000
+++ /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 (file)
index 17ca0fd..0000000
+++ /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.
index 37a3792..36895d2 100644 (file)
 #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)
     {
index 43cda8f..ebc4d25 100644 (file)
@@ -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);
index 2cedca2..98b17fa 100644 (file)
@@ -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
index d6e113b..1872313 100644 (file)
@@ -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
index cd03dce..6c1efd4 100644 (file)
@@ -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],
index 0dc8552..c07ac8b 100644 (file)
@@ -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;
index ce532d7..7c332e0 100644 (file)
@@ -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));
         }
     }
index 24154a8..7660fd1 100644 (file)
@@ -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);