From 931ec44ff27fd2ef78b830bbe20acd2e26576a9f Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Fri, 27 Jan 2023 13:43:55 +0300 Subject: [PATCH] driver-hidpp10: fix integer overflow when profile count is unset Blame C for implicit conversions. --- src/driver-hidpp10.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 1a0c1bc8..2123143c 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -656,7 +656,15 @@ hidpp10drv_probe(struct ratbag_device *device) else if (strcasecmp("G9", typestr) == 0) type = HIDPP10_PROFILE_G9; - profile_count = ratbag_device_data_hidpp10_get_profile_count(device->data); + rc = ratbag_device_data_hidpp10_get_profile_count(device->data); + if (rc == -1) { + log_error(device->ratbag, + "Device %s has no profile count set, even though profiles are enabled. " + "Please adjust the .device file.\n", + device->name); + } else { + profile_count = (unsigned int)rc; + }; } device_idx = ratbag_device_data_hidpp10_get_index(device->data);