]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: avoid reading before empty capability masks
authordongshengyuan <545258830@qq.com>
Mon, 13 Jul 2026 02:30:25 +0000 (10:30 +0800)
committerdongshengyuan <545258830@qq.com>
Mon, 13 Jul 2026 02:59:00 +0000 (10:59 +0800)
When input_id prints a decoded capability bitmap, an all-zero
bitmap can decrement the index to zero.

Check the index before reading bitmask[val - 1].

Reproducer:
  udevadm test-builtin input_id with an all-zero capability mask

Follow-up:
  912541b0246ef315d4d851237483b98c9dd3f992

src/udev/udev-builtin-input_id.c

index ec232f3e9324881b8abb46d5a02120dc5d355e48..532e3ed60b504baf4f3e2c6ce8158036876fb985 100644 (file)
@@ -118,7 +118,7 @@ static void get_cap_mask(
 
                 val = bitmask_size / sizeof (unsigned long);
                 /* skip trailing zeros */
-                while (bitmask[val-1] == 0 && val > 0)
+                while (val > 0 && bitmask[val-1] == 0)
                         --val;
 
                 /* IN_SET() cannot be used in assert_cc(). */