Merge pull request #15561 from poettering/udev-memdup-fix

udev: nulstr NUL termination fix
This commit is contained in:
Lennart Poettering 2020-04-23 19:50:12 +02:00 committed by GitHub
commit 08508c4862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -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)) {