udev: prepare memory for extra NUL termination for NULSTR

Fixes: #15162
This commit is contained in:
Lennart Poettering 2020-04-23 13:36:00 +02:00
parent 2d69cf6eb0
commit cd3c8a117c
1 changed files with 3 additions and 1 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();