|
|
594167 |
From fdc436432f1ca2dd9df2f24728916ab1201015c1 Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
594167 |
Date: Tue, 5 Apr 2022 21:47:46 +0900
|
|
|
594167 |
Subject: [PATCH] core: command argument can be longer than PATH_MAX
|
|
|
594167 |
|
|
|
594167 |
Fixes a bug introduced by 065364920281e1cf59cab989e17aff21790505c4.
|
|
|
594167 |
|
|
|
594167 |
Fixes #22957.
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit 58dd4999dcc81a0ed92fbd78bce3592c3e3afe9e)
|
|
|
594167 |
|
|
|
594167 |
Resolves: #2073994
|
|
|
594167 |
---
|
|
|
594167 |
src/core/load-fragment.c | 2 +-
|
|
|
594167 |
src/test/test-load-fragment.c | 16 ++++++++++++++++
|
|
|
594167 |
2 files changed, 17 insertions(+), 1 deletion(-)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
|
|
|
594167 |
index ad5a0912fc..461e073269 100644
|
|
|
594167 |
--- a/src/core/load-fragment.c
|
|
|
594167 |
+++ b/src/core/load-fragment.c
|
|
|
594167 |
@@ -1000,7 +1000,7 @@ int config_parse_exec(
|
|
|
594167 |
if (r < 0)
|
|
|
594167 |
return ignore ? 0 : -ENOEXEC;
|
|
|
594167 |
|
|
|
594167 |
- r = unit_path_printf(u, word, &resolved);
|
|
|
594167 |
+ r = unit_full_printf(u, word, &resolved);
|
|
|
594167 |
if (r < 0) {
|
|
|
594167 |
log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, r,
|
|
|
594167 |
"Failed to resolve unit specifiers in %s%s: %m",
|
|
|
594167 |
diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c
|
|
|
594167 |
index fbe4744333..c579be4150 100644
|
|
|
594167 |
--- a/src/test/test-load-fragment.c
|
|
|
594167 |
+++ b/src/test/test-load-fragment.c
|
|
|
594167 |
@@ -10,6 +10,7 @@
|
|
|
594167 |
#include "capability-util.h"
|
|
|
594167 |
#include "conf-parser.h"
|
|
|
594167 |
#include "fd-util.h"
|
|
|
594167 |
+#include "fileio.h"
|
|
|
594167 |
#include "format-util.h"
|
|
|
594167 |
#include "fs-util.h"
|
|
|
594167 |
#include "hashmap.h"
|
|
|
594167 |
@@ -416,6 +417,21 @@ TEST(config_parse_exec) {
|
|
|
594167 |
assert_se(r == 0);
|
|
|
594167 |
assert_se(c1->command_next == NULL);
|
|
|
594167 |
|
|
|
594167 |
+ log_info("/* long arg */"); /* See issue #22957. */
|
|
|
594167 |
+
|
|
|
594167 |
+ char x[LONG_LINE_MAX-100], *y;
|
|
|
594167 |
+ y = mempcpy(x, "/bin/echo ", STRLEN("/bin/echo "));
|
|
|
594167 |
+ memset(y, 'x', sizeof(x) - STRLEN("/bin/echo ") - 1);
|
|
|
594167 |
+ x[sizeof(x) - 1] = '\0';
|
|
|
594167 |
+
|
|
|
594167 |
+ r = config_parse_exec(NULL, "fake", 5, "section", 1,
|
|
|
594167 |
+ "LValue", 0, x,
|
|
|
594167 |
+ &c, u);
|
|
|
594167 |
+ assert_se(r >= 0);
|
|
|
594167 |
+ c1 = c1->command_next;
|
|
|
594167 |
+ check_execcommand(c1,
|
|
|
594167 |
+ "/bin/echo", NULL, y, NULL, false);
|
|
|
594167 |
+
|
|
|
594167 |
log_info("/* empty argument, reset */");
|
|
|
594167 |
r = config_parse_exec(NULL, "fake", 4, "section", 1,
|
|
|
594167 |
"LValue", 0, "",
|