From: Lennart Poettering Date: Thu, 23 Apr 2020 11:36:00 +0000 (+0200) Subject: udev: prepare memory for extra NUL termination for NULSTR X-Git-Tag: v246-rc1~513^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd3c8a117ccf3505e49d34324473e2175ef0a9ce;p=thirdparty%2Fsystemd.git udev: prepare memory for extra NUL termination for NULSTR Fixes: #15162 --- diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 6030ffb1f08..3bf3ee56f38 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();