summaryrefslogtreecommitdiff
path: root/src/palrt
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2016-11-04 21:05:51 -0700
committerGitHub <noreply@github.com>2016-11-04 21:05:51 -0700
commite1189d69095320cfb4b11cecde2184793c9b822d (patch)
tree4a0d4f208b6d789620a07cac908f74285425a610 /src/palrt
parent313daa2004df7b93938a50c99165570e3dc29f2b (diff)
downloadcoreclr-e1189d69095320cfb4b11cecde2184793c9b822d.tar.gz
coreclr-e1189d69095320cfb4b11cecde2184793c9b822d.tar.bz2
coreclr-e1189d69095320cfb4b11cecde2184793c9b822d.zip
Remove more PAL functions (#8009)
This change removes the following PAL functions and their related PAL tests: _i64tow _itow lstrcatW lstrcpyW wsprintfA wsprintfW lstrcpynW The lstrcpynW was actually used in two functions in palrt and I have replaced it with StringCchCopyNW. The _i64tow and _itow were used as an implementation of the _i64tow_s and _itow_s. Since these _s versions were also implemented in PAL for its internal purposes, I have exposed them and got rid of the unsafe versions.
Diffstat (limited to 'src/palrt')
-rw-r--r--src/palrt/path.cpp23
-rw-r--r--src/palrt/urlpars.cpp6
2 files changed, 17 insertions, 12 deletions
diff --git a/src/palrt/path.cpp b/src/palrt/path.cpp
index 1d610cd4fb..fc01183e33 100644
--- a/src/palrt/path.cpp
+++ b/src/palrt/path.cpp
@@ -11,7 +11,7 @@
// ===========================================================================
#include "common.h"
-
+#include "strsafe.h"
#define CH_SLASH W('/')
@@ -355,7 +355,8 @@ STDAPI_(BOOL) PathCanonicalizeW(LPWSTR lpszDst, LPCWSTR lpszSrc)
else // Everything else
{
// Just copy it.
- lstrcpynW(lpchDst, lpchSrc, cchPC);
+ int cchRemainingBuffer = MAX_PATH - (lpszDst - lpchDst);
+ StringCchCopyNW(lpchDst, cchRemainingBuffer, lpchSrc, cchPC);
lpchDst += cchPC - 1;
lpchSrc += cchPC - 1;
}
@@ -429,11 +430,12 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
{
if (!lpszFile || *lpszFile==W('\0'))
{
- lstrcpynW(szTemp, lpszDir, ARRAYSIZE(szTemp)); // lpszFile is empty
+ // lpszFile is empty
+ StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszDir, ARRAYSIZE(szTemp));
}
else if (PathIsRelativeW(lpszFile))
{
- lstrcpynW(szTemp, lpszDir, ARRAYSIZE(szTemp));
+ StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszDir, ARRAYSIZE(szTemp));
pszT = PathAddBackslashW(szTemp);
if (pszT)
{
@@ -441,7 +443,7 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
if (lstrlenW(lpszFile) < iRemaining)
{
- lstrcpynW(pszT, lpszFile, iRemaining);
+ StringCchCopyNW(pszT, iRemaining, lpszFile, iRemaining);
}
else
{
@@ -455,7 +457,7 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
}
else if (IsPathSeparator(*lpszFile) && !PathIsUNCW(lpszFile))
{
- lstrcpynW(szTemp, lpszDir, ARRAYSIZE(szTemp));
+ StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszDir, ARRAYSIZE(szTemp));
// FEATURE: Note that we do not check that an actual root is returned;
// it is assumed that we are given valid parameters
PathStripToRootW(szTemp);
@@ -466,7 +468,8 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
// Skip the backslash when copying
// Note: We don't support strings longer than 4GB, but that's
// okay because we already barf at MAX_PATH
- lstrcpynW(pszT, lpszFile+1, (int)(ARRAYSIZE(szTemp) - (pszT - szTemp)));
+ int iRemaining = (int)(ARRAYSIZE(szTemp) - (pszT - szTemp));
+ StringCchCopyNW(pszT, iRemaining, lpszFile+1, iRemaining);
}
else
{
@@ -475,12 +478,14 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
}
else
{
- lstrcpynW(szTemp, lpszFile, ARRAYSIZE(szTemp)); // already fully qualified file part
+ // already fully qualified file part
+ StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszFile, ARRAYSIZE(szTemp));
}
}
else if (lpszFile && *lpszFile)
{
- lstrcpynW(szTemp, lpszFile, ARRAYSIZE(szTemp)); // no dir just use file.
+ // no dir just use file.
+ StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszFile, ARRAYSIZE(szTemp));
}
//
diff --git a/src/palrt/urlpars.cpp b/src/palrt/urlpars.cpp
index 77b0a6e2ba..66289b6f9d 100644
--- a/src/palrt/urlpars.cpp
+++ b/src/palrt/urlpars.cpp
@@ -11,6 +11,7 @@
// ===========================================================================
#include "common.h"
+#include "strsafe.h"
#define SLASH W('/')
#define WHACK W('\\')
@@ -293,14 +294,13 @@ ParseURLW(
// (+ 1) for null terminator.
- StrCpyNW(rgchDebugProtocol, ppu->pszProtocol,
+ StringCchCopyNW(rgchDebugProtocol, ARRAYSIZE(rgchDebugProtocol), ppu->pszProtocol,
min(ppu->cchProtocol + 1, SIZECHARS(rgchDebugProtocol)));
// (+ 1) for null terminator.
- StrCpyNW(rgchDebugSuffix, ppu->pszSuffix,
+ StringCchCopyNW(rgchDebugSuffix, ARRAYSIZE(rgchDebugSuffix), ppu->pszSuffix,
min(ppu->cchSuffix + 1, SIZECHARS(rgchDebugSuffix)));
-
}
#endif