mirror of
https://github.com/Lekensteyn/ltunify.git
synced 2025-12-08 17:53:23 +00:00
Fix logic flaw in array bounds
Index 0xFF needs an array of size 0x100... This error was caught with Address Sanitizer while trying to iterate through all registers 0x00..0xFF.
This commit is contained in:
6
hidraw.c
6
hidraw.c
@@ -50,7 +50,7 @@ struct report {
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
static const char * report_types[0xFF] = {
|
||||
static const char * report_types[0x100] = {
|
||||
// 0x00 - 0x3F HID reports
|
||||
[0x01] = "KEYBOARD",
|
||||
[0x02] = "MOUSE",
|
||||
@@ -78,7 +78,7 @@ static const char * report_types[0xFF] = {
|
||||
[0x8F] = "_ERROR_MSG",
|
||||
};
|
||||
|
||||
static const char * error_messages[0xFF] = {
|
||||
static const char * error_messages[0x100] = {
|
||||
// error messages for type=8F (ERROR_MSG)
|
||||
[0x01] = "SUCCESS",
|
||||
[0x02] = "INVALID_SUBID",
|
||||
@@ -96,7 +96,7 @@ static const char * error_messages[0xFF] = {
|
||||
};
|
||||
|
||||
// everything with a '?' is guessed
|
||||
static const char * registers[0xFF] = {
|
||||
static const char * registers[0x100] = {
|
||||
[0x00] = "ENABLED_NOTIFS",
|
||||
[0x01] = "KBD_HAND_DETECT?",
|
||||
[0x02] = "CONNECTION_STATE",
|
||||
|
||||
@@ -197,7 +197,7 @@ struct device {
|
||||
struct device devices[DEVICES_MAX];
|
||||
|
||||
// error messages for type=8F (ERROR_MSG)
|
||||
static const char * error_messages[0xFF] = {
|
||||
static const char * error_messages[0x100] = {
|
||||
[0x01] = "SUCCESS",
|
||||
[0x02] = "INVALID_SUBID",
|
||||
[0x03] = "INVALID_ADDRESS",
|
||||
@@ -213,7 +213,7 @@ static const char * error_messages[0xFF] = {
|
||||
[0x0d] = "WRONG_PIN_CODE",
|
||||
};
|
||||
|
||||
static const char * device_type[0x0F] = {
|
||||
static const char * device_type[0x10] = {
|
||||
[0x00] = "Unknown",
|
||||
[0x01] = "Keyboard",
|
||||
[0x02] = "Mouse",
|
||||
|
||||
Reference in New Issue
Block a user