From 09465a9083e1627776fdf2720e7117be5e41915a Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 30 Nov 2021 21:10:10 +0300 Subject: [PATCH] hidapi, windows: replace a strncpy() with plain memcpy() mainstream has a similar change, already. --- src/hidapi/windows/hid.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/hidapi/windows/hid.c b/src/hidapi/windows/hid.c index 2f617692e..f0a30c7d1 100644 --- a/src/hidapi/windows/hid.c +++ b/src/hidapi/windows/hid.c @@ -53,7 +53,6 @@ typedef LONG NTSTATUS; #define memset SDL_memset #define strcmp SDL_strcmp #define strlen SDL_strlen -#define strncpy SDL_strlcpy #define strstr SDL_strstr #define strtol SDL_strtol #define wcscmp SDL_wcscmp @@ -105,9 +104,6 @@ extern "C" { #define MIN(x,y) ((x) < (y)? (x): (y)) #ifdef _MSC_VER - /* Thanks Microsoft, but I know how to use strncpy(). */ - #pragma warning(disable:4996) - /* Yes, we have some unreferenced formal parameters */ #pragma warning(disable:4100) #endif @@ -550,8 +546,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor if (str) { len = strlen(str); cur_dev->path = (char*) calloc(len+1, sizeof(char)); - strncpy(cur_dev->path, str, len+1); - cur_dev->path[len] = '\0'; + memcpy(cur_dev->path, str, len+1); } else cur_dev->path = NULL;