From 716cb7ea87e40abb4b106df55af7ff4666170296 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Mon, 21 Nov 2016 16:22:45 +0100 Subject: Remove unsafe banned functions (#8162) This change removes _snwprintf, _snprintf and _vsnwprintf usage from CoreCLR and their implementations from PAL. PAL exposes their secure variants instead and CoreCLR now uses those instead. I have also removed the StringCchPrintfA/W, StringCchVPrintfA/W, StringCbVPrintfA/W, StringCbPrintfA/W, StringCbPrintfExA/W, StringCchVPrintfExA/W, StringCbVPrintfExA/W and StringCchPrintfExA/W replaced their usage by the secure variants of the sprintf functions, since they were used at only few places and implementing all of the variants using the secure sprintf variants would be a hassle. I also needed to fix a missing support for size modifiers for %p formatting character and for wide characters / strings in the secure sprintf functions that was revealed by the PAL tests. I have also removed a bunch of PAL tests that were using %n formatting character which was not implemented since it is considered unsafe and translated PAL tests that were using the removed functions to use the safe variants of those. --- src/utilcode/sstring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/utilcode') diff --git a/src/utilcode/sstring.cpp b/src/utilcode/sstring.cpp index 154e9ded7a..ce532d70f6 100644 --- a/src/utilcode/sstring.cpp +++ b/src/utilcode/sstring.cpp @@ -2211,7 +2211,7 @@ void SString::VPrintf(const WCHAR *format, va_list args) else if (errno!=0 && errno!=EBADF && errno!=ERANGE) { - CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf failed. Potential globalization bug."); + CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf_s failed. Potential globalization bug."); ThrowHR(HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION)); } } @@ -2293,7 +2293,7 @@ void SString::PVPrintf(const WCHAR *format, va_list args) else if (errno!=0 && errno!=EBADF && errno!=ERANGE) { - CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf failed. Potential globalization bug."); + CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf_s failed. Potential globalization bug."); ThrowHR(HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION)); } } -- cgit v1.2.3