Skip to content

Commit bf23c9e

Browse files
committed
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
1 parent bd7d180 commit bf23c9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

udev_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static void make_bit(unsigned long *arr, int cnt, const char *str)
389389

390390
static int test_bit(unsigned long *arr, unsigned long bit)
391391
{
392-
return arr[BIT_WORD(bit)] & BIT_MASK(bit);
392+
return !!(arr[BIT_WORD(bit)] & BIT_MASK(bit));
393393
}
394394

395395
static void set_properties_from_evdev(struct udev_device *udev_device)

0 commit comments

Comments
 (0)