Skip to content

Commit

Permalink
Fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Jan 29, 2019
1 parent 2684efe commit 04f4637
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions hidapi/windows/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,17 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
/* Fill out the record */
cur_dev->next = NULL;
str = device_interface_detail_data->DevicePath;
cur_dev->path = NULL;
if (str) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
len = strlen(str);
cur_dev->path = (char*) calloc(len+1, sizeof(char));
strncpy(cur_dev->path, str, len+1);
cur_dev->path[len] = '\0';
len = min(len, 1000); // Do not accept device paths over 1000 bytes to about possible overflows
cur_dev->path = (char*) calloc(len+1, sizeof(char));
strncpy(cur_dev->path, str, len+2);
cur_dev->path[len] = '\0';
#pragma GCC diagnostic pop
}
else
cur_dev->path = NULL;

/* Serial Number */
res = HidD_GetSerialNumberString(write_handle, wstr, sizeof(wstr));
Expand Down

0 comments on commit 04f4637

Please sign in to comment.