]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: prepare memory for extra NUL termination for NULSTR
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 11:36:00 +0000 (13:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 11:56:21 +0000 (13:56 +0200)
Fixes: #15162
src/udev/udev-rules.c

index 6030ffb1f088f46fb582c80a45c8219e2819e50b..3bf3ee56f382a6429128a51c9f6129cd4bcbf5c0 100644 (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();