mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
HID: steam: Zero-initialize reply in serial lookup
When requesting the serial number from a controller, the function will do some basic bounds checking to make sure the reply is valid, as well as capping off the reply with a null byte before copying. However, the error logging can leak uninitialized memory in some cases. We can simplify and solve this by just zero-initalizing the reply memory eagerly instead. Signed-off-by: Vicki Pfau <vi@endrift.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
de435b770c
commit
9f8ee99f83
|
|
@ -488,7 +488,7 @@ static int steam_get_serial(struct steam_device *steam)
|
|||
*/
|
||||
int ret = 0;
|
||||
u8 cmd[] = {ID_GET_STRING_ATTRIBUTE, sizeof(steam->serial_no), ATTRIB_STR_UNIT_SERIAL};
|
||||
u8 reply[3 + STEAM_SERIAL_LEN + 1];
|
||||
u8 reply[3 + STEAM_SERIAL_LEN + 1] = {0};
|
||||
|
||||
guard(mutex)(&steam->report_mutex);
|
||||
ret = steam_send_report(steam, cmd, sizeof(cmd));
|
||||
|
|
@ -503,7 +503,6 @@ static int steam_get_serial(struct steam_device *steam)
|
|||
(int)sizeof(reply), reply);
|
||||
return -EIO;
|
||||
}
|
||||
reply[3 + STEAM_SERIAL_LEN] = 0;
|
||||
strscpy(steam->serial_no, reply + 3, reply[1]);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user