udev-rules: fix matching of token types that support alternative patterns
authorDmitry V. Levin <ldv@strace.io>
Thu, 16 Mar 2023 08:00:00 +0000 (08:00 +0000)
committerDmitry V. Levin <ldv@strace.io>
Sun, 19 Mar 2023 11:32:09 +0000 (11:32 +0000)
commitc43ff248f94266cfc93e300a2d3d163ed805e55b
tree3e16f57b582bdab32f1342f9de53bf2851c09ba4
parent432f1fa8c745cae452d69530642b1e9ec557d58a
udev-rules: fix matching of token types that support alternative patterns

For those token types that support matching of alternative patterns,
their token values are interpreted as nulstr, so make sure the parser
does the right thing and makes these token values terminated by two
subsequent NULs so they could be safely interpreted as nulstr.

Before this fix, the following rules would result to "echo foo" invocation:
  ENV{foo}=", RUN"
  ENV{foo}=="bar", RUN+="echo foo"
because the value of `ENV{foo}` is treated as nulstr, and it used to match
against alternative patterns, in this case `bar`, `, RUN`, and `="echo foo`.

Fixes: 25de7aa7b90c ("udev: modernize udev-rules.c")
src/shared/udev-util.c
src/test/test-udev-util.c