X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Fudev-rules.c;h=8c0e1d961b4618c99c05c63f7b5f7f0ab72e0f03;hb=91a75e4ad4071d9d0ce1adb5c8d8272aac379d0a;hp=0643811d7a458809bf6d5e517f0f55dd4d8f886d;hpb=b62557daff59dbe3096dc31ac1f42a20ff6a9f92;p=elogind.git diff --git a/udev/udev-rules.c b/udev/udev-rules.c index 0643811d7..8c0e1d961 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -1726,21 +1726,26 @@ static int match_key(struct udev_rules *rules, struct token *token, const char * break; case GL_SPLIT: { - char value[UTIL_PATH_SIZE]; + const char *split; + size_t len; - util_strlcpy(value, &rules->buf[token->key.value_off], sizeof(value)); - key_value = value; - while (key_value != NULL) { - pos = strchr(key_value, '|'); - if (pos != NULL) { - pos[0] = '\0'; - pos = &pos[1]; - } - dbg(rules->udev, "match %s '%s' <-> '%s'\n", token_str[token->type], key_value, val); - match = (strcmp(key_value, val) == 0); - if (match) + split = &rules->buf[token->key.value_off]; + len = strlen(val); + while (1) { + const char *next; + + next = strchr(split, '|'); + if (next != NULL) { + size_t matchlen = (size_t)(next - split); + + match = (matchlen == len && strncmp(split, val, matchlen) == 0); + if (match) + break; + } else { + match = (strcmp(split, val) == 0); break; - key_value = pos; + } + split = &next[1]; } break; }