Commit 09465a9083e1627776fdf2720e7117be5e41915a

Ozkan Sezer 2021-11-30T21:10:10

hidapi, windows: replace a strncpy() with plain memcpy() mainstream has a similar change, already.

diff --git a/src/hidapi/windows/hid.c b/src/hidapi/windows/hid.c
index 2f61769..f0a30c7 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;