summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorYi Zhang (CLR) <yzha@microsoft.com>2016-04-07 22:12:06 -0700
committerYi Zhang (CLR) <yzha@microsoft.com>2016-04-07 22:14:24 -0700
commit78595418e12b1059e94b3b5d031da007b1be6794 (patch)
tree3d797fa1b6bb19c315206ca5ca1c1846a86a297a /tests/src
parentbe8155b7594badb580932e18f05bf390e26ba59f (diff)
downloadcoreclr-78595418e12b1059e94b3b5d031da007b1be6794.tar.gz
coreclr-78595418e12b1059e94b3b5d031da007b1be6794.tar.bz2
coreclr-78595418e12b1059e94b3b5d031da007b1be6794.zip
Fix LPSTR test failure due to incorrect implementation of strncpy_s. It was implemented using snprintf and didn't account for the null terminator behavioral difference. Test is now passing after the fix. We should see if we can always use xplat helpers in all platforms for easier debugging.
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/Interop/common/xplatform.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/src/Interop/common/xplatform.h b/tests/src/Interop/common/xplatform.h
index e488d0c613..451209b430 100644
--- a/tests/src/Interop/common/xplatform.h
+++ b/tests/src/Interop/common/xplatform.h
@@ -115,7 +115,9 @@ public:
// function implementation
size_t strncpy_s(char* strDest, size_t numberOfElements, const char *strSource, size_t count)
{
- return snprintf(strDest, count, "%s", strSource);
+ // NOTE: Need to pass count + 1 since strncpy_s does not count null,
+ // while snprintf does.
+ return snprintf(strDest, count + 1, "%s", strSource);
}
size_t strcpy_s(char *dest, size_t n, char const *src)