summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2015-02-06 12:54:46 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2015-02-06 13:38:33 +0100
commit59b2fd40eb3b248f88f972a6403d3f77bf4b5c0e (patch)
treefe9e0048e2392030f5b55fabe016b2e881684bb7
parent95d04aa1134b3bcbf79d2c8aa4102ec486c59b80 (diff)
Use new vdagent_{strncpy,strcat}_s helpers
-rw-r--r--common/vdcommon.cpp8
-rw-r--r--common/vdcommon.h5
-rw-r--r--vdagent/file_xfer.cpp4
-rw-r--r--vdagent/file_xfer.h2
4 files changed, 12 insertions, 7 deletions
diff --git a/common/vdcommon.cpp b/common/vdcommon.cpp
index 40c9e13..5b52b1a 100644
--- a/common/vdcommon.cpp
+++ b/common/vdcommon.cpp
@@ -49,7 +49,9 @@ errno_t vdagent_strcat_s(char *strDestination,
return ERANGE;
}
- return strcat(strDestination, strSource);
+ strcat(strDestination, strSource);
+
+ return 0;
}
#endif
@@ -67,6 +69,8 @@ errno_t vdagent_strcpy_s(char *strDestination,
return ERANGE;
}
- return strcpy(strDestination, strSource);
+ strcpy(strDestination, strSource);
+
+ return 0;
}
#endif
diff --git a/common/vdcommon.h b/common/vdcommon.h
index 01bbbc8..db9257f 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -22,6 +22,7 @@
#pragma warning(disable:4200)
#endif
+#include <errno.h>
#include <windows.h>
#include "spice/vd_agent.h"
#include "vdlog.h"
@@ -78,7 +79,7 @@ typedef CRITICAL_SECTION mutex_t;
#else
errno_t vdagent_strcat_s(char *strDestination,
size_t numberOfElements,
- const char *strSource)
+ const char *strSource);
#endif
#ifdef HAVE_STRCPY_S
@@ -86,7 +87,7 @@ errno_t vdagent_strcat_s(char *strDestination,
#else
errno_t vdagent_strcpy_s(char *strDestination,
size_t numberOfElements,
- const char *strSource)
+ const char *strSource);
#endif
#ifdef _MSC_VER // compiling with Visual Studio
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 8d7c86c..9e0bcda 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -87,8 +87,8 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
return;
}
- strcat(file_path, "\\");
- strcat(file_path, file_name);
+ vdagent_strcat_s(file_path, sizeof(file_path), "\\");
+ vdagent_strcat_s(file_path, sizeof(file_path), file_name);
if((wlen = MultiByteToWideChar(CP_UTF8, 0, file_path, -1, NULL, 0)) == 0){
vd_printf("failed getting WideChar length of %s", file_path);
return;
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
index 07a6808..7f756e3 100644
--- a/vdagent/file_xfer.h
+++ b/vdagent/file_xfer.h
@@ -27,7 +27,7 @@ typedef struct ALIGN_VC FileXferTask {
// 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);
+ vdagent_strncpy_s(name, sizeof(name), _name);
}
HANDLE handle;
uint64_t size;