summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-07-12 21:46:22 +0900
committerGitHub <noreply@github.com>2020-07-12 21:46:22 +0900
commit5553041a623f003ba978d3888c458651f525e647 (patch)
tree0432c52e043fc03c8f40d3cdc65b2e795749579c
parent6b949d26059ce221ae5fbf5c738e95f6b2859788 (diff)
parent0d3a8bc7ebd76591e14f7098b4266fd2065ac4db (diff)
downloadsystemd-5553041a623f003ba978d3888c458651f525e647.tar.gz
Merge pull request #16435 from gaoyi1988/master
fix multi matches when use "||"
-rw-r--r--src/udev/udev-rules.c5
-rwxr-xr-xtest/udev-test.pl11
2 files changed, 16 insertions, 0 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 4efafffd40..2d4eb3d341 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -452,6 +452,11 @@ static int rule_line_add_token(UdevRuleLine *rule_line, UdevRuleTokenType type,
}
}
*b = '\0';
+
+ /* Make sure the value is end, so NULSTR_FOREACH can read correct match */
+ if (b < a)
+ b[1] = '\0';
+
if (bar)
empty = true;
diff --git a/test/udev-test.pl b/test/udev-test.pl
index 95013279b8..2480e4120b 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -1325,6 +1325,17 @@ TAGS=="aaa|bbb", SYMLINK+="bad"
EOF
},
{
+ desc => "test multi matches 11",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+ exp_name => "found",
+ not_exp_name => "bad",
+ rules => <<EOF
+KERNEL=="sda", TAG="c"
+TAGS=="foo||bar||c", SYMLINK+="found"
+TAGS=="aaa||bbb||ccc", SYMLINK+="bad"
+EOF
+ },
+ {
desc => "IMPORT parent test sequence 1/2 (keep)",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
exp_name => "parent",