Francois Gouget : testbot/TestLauncher: The str*_s() functions are not portable. Avoid them.
Module: tools Branch: master Commit: 814671cfc719a5980b513bdb61cbe7e012934644 URL: http://source.winehq.org/git/tools.git/?a=commit;h=814671cfc719a5980b513bdb6... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Wed Jun 14 10:42:43 2017 +0200 testbot/TestLauncher: The str*_s() functions are not portable. Avoid them. They are missing in older versions of msvcrt, on Windows XP for instance. Also, simply mapping strncpy_s() to strncpy() means the string will not be NUL-terminated! The destination buffers are large enough anyway so use the regular string functions. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- testbot/src/TestLauncher/TestLauncher.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/testbot/src/TestLauncher/TestLauncher.c b/testbot/src/TestLauncher/TestLauncher.c index ed7fffb..53590f8 100644 --- a/testbot/src/TestLauncher/TestLauncher.c +++ b/testbot/src/TestLauncher/TestLauncher.c @@ -19,13 +19,9 @@ */ #include <stdio.h> +#include <errno.h> #include <windows.h> -#ifdef __MINGW32__ -#define strcpy_s(dest, size, src) strcpy((dest), (src)) -#define strncpy_s(dest, size, src, max) strncpy((dest), (src), (max)) -#define strcat_s(dest, size, src) strcat((dest), (src)) -#endif #define countof(Array) (sizeof(Array) / sizeof(Array[0])) static unsigned Failures = 0; @@ -339,9 +335,12 @@ int main(int argc, char *argv[]) if (Suffix == NULL) Suffix = strchr(TestExeFileName, '.'); if (Suffix == NULL) - strcpy_s(TestName, countof(TestName), TestExeFileName); + strcpy(TestName, TestExeFileName); else - strncpy_s(TestName, _MAX_PATH, TestExeFileName, Suffix - TestExeFileName); + { + strncpy(TestName, TestExeFileName, Suffix - TestExeFileName); + TestName[Suffix - TestExeFileName] = '\0'; + } Subtest = (Arg + 1 < argc ? argv[Arg + 1] : ""); CommandLen = strlen(TestExeFullName) + 3; @@ -356,13 +355,13 @@ int main(int argc, char *argv[]) } CommandLine[0] = '"'; - strcpy_s(CommandLine + 1, CommandLen - 1, TestExeFullName); - strcat_s(CommandLine, CommandLen, "\""); + strcpy(CommandLine + 1, TestExeFullName); + strcat(CommandLine, "\""); for (TestArg = Arg + 1; TestArg < argc; TestArg++) { - strcat_s(CommandLine, CommandLen, " \""); - strcat_s(CommandLine, CommandLen, argv[TestArg]); - strcat_s(CommandLine, CommandLen, "\""); + strcat(CommandLine, " \""); + strcat(CommandLine, argv[TestArg]); + strcat(CommandLine, "\""); } Arg = argc;
participants (1)
-
Alexandre Julliard