summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorUri Lublin <uril@redhat.com>2014-11-25 18:48:08 +0200
committerUri Lublin <uril@redhat.com>2014-12-30 17:37:26 +0200
commitd752a5b6e0cc41879feeebc05e751d8425727671 (patch)
treeecd3e16cbbc3c1b2601df314368756a84382a180 /common
parentc76e541bbad9243043733004c95ee5955a9560dd (diff)
Fix Visual Studio compiler warning (strncpy)
Visual Studio complains: vdagent\file_xfer.h(28) : warning C4996: 'strncpy': This function or variable may Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. Replace strncpy with strcpy_s when building with Visual Studio. Adjust parameter order and difference in meaning of length: - length param is last in strncpy and second in strcpy_s - many calls to strncpy are given length param n-1, as strncpy does not guarantee that destination ends with '\0' - it's safer to set length param not larger than sizeof(d) (assuming d is an array not a pointer) Trying to use strcpy_s for both Visual Studio and mingw failed as strcpy_s is missing from the default msvcrt.dll on WinXP (See OLDMSVCRT in common/vdcommon.h).
Diffstat (limited to 'common')
-rw-r--r--common/vdcommon.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/common/vdcommon.h b/common/vdcommon.h
index 568e3ba..f285175 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -70,6 +70,7 @@ typedef CRITICAL_SECTION mutex_t;
#ifdef _MSC_VER // compiling with Visual Studio
#define snprintf sprintf_s
+#define strncpy(d,s,n) strcpy_s(s, __min(n+1, sizeof(d)), s)
#endif
enum SystemVersion {