Guard against zero length buffers in hid_write (#279)

This commit is contained in:
Erik OShaughnessy
2021-06-13 20:09:13 -05:00
committed by GitHub
parent fc8fdd2bf4
commit 7620bc7faa
4 changed files with 25 additions and 2 deletions
+7 -1
View File
@@ -1043,9 +1043,15 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
{
int res;
int report_number = data[0];
int report_number;
int skipped_report_id = 0;
if (!data || (length ==0)) {
return -1;
}
report_number = data[0];
if (report_number == 0x0) {
data++;
length--;