mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
hidpp10: fix a coverity warning about OOB access
Make sure that the index we pass into long_clear_bit is never higher than the number of bits in the single long we use as array here. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
3844a60837
commit
7eadd20879
@@ -1450,8 +1450,12 @@ hidpp10_read_profile(struct hidpp10_device *dev, uint8_t number)
|
||||
long_clear_bit(&pages, 0);
|
||||
long_clear_bit(&pages, 1);
|
||||
|
||||
for (i = 0; i < dev->profile_count; i++)
|
||||
long_clear_bit(&pages, dev->profiles[i].page);
|
||||
for (i = 0; i < dev->profile_count; i++) {
|
||||
uint8_t page = dev->profiles[i].page;
|
||||
|
||||
assert(page < sizeof(pages) * 8);
|
||||
long_clear_bit(&pages, page);
|
||||
}
|
||||
|
||||
page = ffsl(pages) - 1;
|
||||
profile->page = page;
|
||||
|
||||
Reference in New Issue
Block a user