Commit
9b917abe02505d4ad09c4963ec5a4b2744eb2fee (udev-builtin:
simplify code a bit) changed builtin lookup from copying the first
command word and comparing it with streq() to comparing only the first
command word length with strneq().
That made prefixes such as "k" or "key" resolve to the "keyboard"
builtin, depending on the builtins table order. This was not the
original behavior.
Require the matched builtin name to end at the first command word
boundary so only complete builtin names are accepted. Arguments after
the builtin name continue to work as before.
command += strspn(command, WHITESPACE);
n = strcspn(command, WHITESPACE);
for (UdevBuiltinCommand i = 0; i < _UDEV_BUILTIN_MAX; i++)
- if (builtins[i] && strneq(builtins[i]->name, command, n))
+ if (builtins[i] &&
+ strlen(builtins[i]->name) == n &&
+ strneq(builtins[i]->name, command, n))
return i;
return _UDEV_BUILTIN_INVALID;
# Builtins
(! udevadm test-builtin aaaaa /dev/null)
+(! udevadm test-builtin k /dev/null)
+(! udevadm test-builtin key /dev/null)
udevadm test-builtin blkid "$loopdev"
(! udevadm test-builtin "btrfs" "$loopdev")
(! udevadm test-builtin "btrfs aaaaa" "$loopdev")