diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 6030ffb1f0..4c955b0c07 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1092,7 +1092,9 @@ static int rule_add_line(UdevRules *rules, const char *line_str, unsigned line_n if (isempty(line_str)) return 0; - line = strdup(line_str); + /* We use memdup_suffix0() here, since we want to add a second NUL byte to the end, since possibly + * some parsers might turn this into a "nulstr", which requires an extra NUL at the end. */ + line = memdup_suffix0(line_str, strlen(line_str) + 1); if (!line) return log_oom(); @@ -1328,11 +1330,7 @@ static bool token_match_string(UdevRuleToken *token, const char *str) { match = isempty(str); break; case MATCH_TYPE_SUBSYSTEM: - NULSTR_FOREACH(i, "subsystem\0class\0bus\0") - if (streq(i, str)) { - match = true; - break; - } + match = STR_IN_SET(str, "subsystem", "class", "bus"); break; case MATCH_TYPE_PLAIN_WITH_EMPTY: if (isempty(str)) {