From 51dc0efba3568b598359930901dc6647e9b2c6a1 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 19 Sep 2019 10:00:40 +0200 Subject: [PATCH] Revert back to correct Windows behavior, fixes #7 (#8) * revert back to previous behaviour, fixes #7 * hide gcc warning about strncopy overflow --- hidapi/windows/hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hidapi/windows/hid.c b/hidapi/windows/hid.c index 4e92cc8..60da646 100644 --- a/hidapi/windows/hid.c +++ b/hidapi/windows/hid.c @@ -74,6 +74,8 @@ extern "C" { #pragma warning(disable:4996) #endif +#pragma GCC diagnostic ignored "-Wstringop-overflow" + #ifdef __cplusplus extern "C" { #endif @@ -428,7 +430,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, sizeof(cur_dev->path)); + strncpy(cur_dev->path, str, len+1); cur_dev->path[len] = '\0'; } else