]> err.no Git - systemd/commitdiff
fix possible endless loop for GOTO to non-existent LABEL
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 13 May 2009 16:01:32 +0000 (18:01 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 13 May 2009 16:01:32 +0000 (18:01 +0200)
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526365

test/udev-test.pl
udev/udev-rules.c

index 4f61ce3e5ddf0b40fda8c928032f1ffeccf26693..788bbeac259de7a9fa59dd65357f6ab073e8272f 100755 (executable)
@@ -1554,6 +1554,17 @@ KERNEL=="sda1", GOTO="BAD"
 KERNEL=="sda1", NAME="", LABEL="NO"
 KERNEL=="sda1", NAME="right", LABEL="TEST"
 KERNEL=="sda1", LABEL="BAD"
+EOF
+       },
+       {
+               desc            => "GOTO label does not exist",
+               subsys          => "block",
+               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
+               exp_name        => "right",
+               rules           => <<EOF
+KERNEL=="sda1", GOTO="does-not-exist"
+KERNEL=="sda1", NAME="right",
+LABEL="exists"
 EOF
        },
        {
index fac418e526a625099d8b96adec4711b50fd2b3fb..b8b7e52c839f2b93c06c7ee41a726b3fe6e93408 100644 (file)
@@ -1610,6 +1610,7 @@ static int parse_file(struct udev_rules *rules, const char *filename, unsigned s
                                if (strcmp(label, &rules->buf[rules->tokens[j].rule.label_off]) != 0)
                                        continue;
                                rules->tokens[i].key.rule_goto = j;
+                               break;
                        }
                        if (rules->tokens[i].key.rule_goto == 0)
                                err(rules->udev, "GOTO '%s' has no matching label in: '%s'\n", label, filename);
@@ -2504,6 +2505,8 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                                break;
                        }
                case TK_A_GOTO:
+                       if (cur->key.rule_goto == 0)
+                               break;
                        cur = &rules->tokens[cur->key.rule_goto];
                        continue;
                case TK_A_LAST_RULE: