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:
Peter Hutterer
2017-08-31 09:25:06 +10:00
committed by Benjamin Tissoires
parent 3844a60837
commit 7eadd20879

View File

@@ -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;