summaryrefslogtreecommitdiffstats
path: root/src/tmpfiles/tmpfiles.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-05-09 18:46:48 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-05-12 03:26:07 +0200
commit065364920281e1cf59cab989e17aff21790505c4 (patch)
treeeb7c2c1045de0b868d706a1b68d6d3e4e0aac394 /src/tmpfiles/tmpfiles.c
parentdns-domain: use DNS_LABEL_MAX at one more place (diff)
downloadsystemd-065364920281e1cf59cab989e17aff21790505c4.tar.xz
systemd-065364920281e1cf59cab989e17aff21790505c4.zip
tree-wide: refuse too long strings earlier in specifier_printf()
We usually call specifier_printf() and then check the validity of the result. In many cases, validity checkers, e.g. path_is_valid(), refuse too long strings. This makes specifier_printf() refuse such long results earlier. Moreover, unit_full_string() and description field in sysuser now refuse results longer than LONG_LINE_MAX. config_parse() already refuses the line longer than LONG_LINE_MAX. Hence, it should be ok to set the same value as the maximum length of the resolved string.
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r--src/tmpfiles/tmpfiles.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 9529b09b3f..1e09c256b0 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -2522,7 +2522,7 @@ static int specifier_expansion_from_arg(Item *i) {
if (r < 0)
return log_error_errno(r, "Failed to unescape parameter to write: %s", i->argument);
- r = specifier_printf(unescaped, specifier_table, NULL, &resolved);
+ r = specifier_printf(unescaped, PATH_MAX-1, specifier_table, NULL, &resolved);
if (r < 0)
return r;
@@ -2532,7 +2532,7 @@ static int specifier_expansion_from_arg(Item *i) {
case SET_XATTR:
case RECURSIVE_SET_XATTR:
STRV_FOREACH(xattr, i->xattrs) {
- r = specifier_printf(*xattr, specifier_table, NULL, &resolved);
+ r = specifier_printf(*xattr, SIZE_MAX, specifier_table, NULL, &resolved);
if (r < 0)
return r;
@@ -2706,7 +2706,7 @@ static int parse_line(
i.append_or_force = append_or_force;
i.allow_failure = allow_failure;
- r = specifier_printf(path, specifier_table, NULL, &i.path);
+ r = specifier_printf(path, PATH_MAX-1, specifier_table, NULL, &i.path);
if (r == -ENXIO)
return log_unresolvable_specifier(fname, line);
if (r < 0) {