From bf23c9e5ba310ffc6ef2d67dc07c23efe48c61ae Mon Sep 17 00:00:00 2001 From: illiliti Date: Sat, 26 Jun 2021 01:14:10 +0300 Subject: [PATCH] udev_device.c: fix integer overflow Bitwise AND operation can produce value that may be larger than test_bit() return value. Convert result to bool using `!!` to avoid integer overflow. Fixes: #33 --- udev_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/udev_device.c b/udev_device.c index 86d1e983..7957bb23 100644 --- a/udev_device.c +++ b/udev_device.c @@ -389,7 +389,7 @@ static void make_bit(unsigned long *arr, int cnt, const char *str) static int test_bit(unsigned long *arr, unsigned long bit) { - return arr[BIT_WORD(bit)] & BIT_MASK(bit); + return !!(arr[BIT_WORD(bit)] & BIT_MASK(bit)); } static void set_properties_from_evdev(struct udev_device *udev_device)