Skip to content

Commit 844e468

Browse files
authored
Fix: memory write out of bounds. (signal11#418)
1 parent 93285f5 commit 844e468

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

windows/hid.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ int HID_API_EXPORT_CALL HID_API_CALL hid_get_manufacturer_string(hid_device *dev
10811081
}
10821082

10831083
wcsncpy(string, dev->device_info->manufacturer_string, maxlen);
1084-
string[maxlen] = L'\0';
1084+
string[maxlen - 1] = L'\0';
10851085

10861086
return 0;
10871087
}
@@ -1102,7 +1102,7 @@ int HID_API_EXPORT_CALL HID_API_CALL hid_get_product_string(hid_device *dev, wch
11021102

11031103

11041104
wcsncpy(string, dev->device_info->product_string, maxlen);
1105-
string[maxlen] = L'\0';
1105+
string[maxlen - 1] = L'\0';
11061106

11071107
return 0;
11081108
}
@@ -1123,7 +1123,7 @@ int HID_API_EXPORT_CALL HID_API_CALL hid_get_serial_number_string(hid_device *de
11231123

11241124

11251125
wcsncpy(string, dev->device_info->serial_number, maxlen);
1126-
string[maxlen] = L'\0';
1126+
string[maxlen - 1] = L'\0';
11271127

11281128
return 0;
11291129
}

0 commit comments

Comments
 (0)