From cd3c8a117ccf3505e49d34324473e2175ef0a9ce Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 23 Apr 2020 13:36:00 +0200 Subject: [PATCH] udev: prepare memory for extra NUL termination for NULSTR Fixes: #15162 --- src/udev/udev-rules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(); -- 2.47.3