diff options
author | Uri Lublin <uril@redhat.com> | 2014-11-25 18:48:08 +0200 |
---|---|---|
committer | Uri Lublin <uril@redhat.com> | 2014-12-30 17:37:26 +0200 |
commit | d752a5b6e0cc41879feeebc05e751d8425727671 (patch) | |
tree | ecd3e16cbbc3c1b2601df314368756a84382a180 /vdagent | |
parent | c76e541bbad9243043733004c95ee5955a9560dd (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 'vdagent')
-rw-r--r-- | vdagent/file_xfer.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h index b506f59..07a6808 100644 --- a/vdagent/file_xfer.h +++ b/vdagent/file_xfer.h @@ -25,6 +25,8 @@ typedef struct ALIGN_VC FileXferTask { FileXferTask(HANDLE _handle, uint64_t _size, char* _name): handle(_handle), size(_size), pos(0) { // FIXME: should raise an error if name is too long.. + // currently the only user is FileXfer::handle_start + // which verifies that strlen(_name) < MAX_PATH strncpy(name, _name, sizeof(name) - 1); } HANDLE handle; |