summaryrefslogtreecommitdiffstats
path: root/src/partition
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/partition
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/partition')
-rw-r--r--src/partition/repart.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 51b8f20dbc..1ecd9ffea4 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -977,7 +977,7 @@ static int config_parse_label(
/* Nota bene: the empty label is a totally valid one. Let's hence not follow our usual rule of
* assigning the empty string to reset to default here, but really accept it as label to set. */
- r = specifier_printf(rvalue, specifier_table, NULL, &resolved);
+ r = specifier_printf(rvalue, GPT_LABEL_MAX, specifier_table, NULL, &resolved);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in Label=, ignoring: %s", rvalue);
@@ -1142,7 +1142,7 @@ static int config_parse_copy_files(
if (!isempty(p))
return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Too many arguments: %s", rvalue);
- r = specifier_printf(source, specifier_table, NULL, &resolved_source);
+ r = specifier_printf(source, PATH_MAX-1, specifier_table, NULL, &resolved_source);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in CopyFiles= source, ignoring: %s", rvalue);
@@ -1153,7 +1153,7 @@ static int config_parse_copy_files(
if (r < 0)
return 0;
- r = specifier_printf(target, specifier_table, NULL, &resolved_target);
+ r = specifier_printf(target, PATH_MAX-1, specifier_table, NULL, &resolved_target);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in CopyFiles= target, ignoring: %s", resolved_target);
@@ -1202,7 +1202,7 @@ static int config_parse_copy_blocks(
return 0;
}
- r = specifier_printf(rvalue, specifier_table, NULL, &d);
+ r = specifier_printf(rvalue, PATH_MAX-1, specifier_table, NULL, &d);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in CopyBlocks= source path, ignoring: %s", rvalue);
@@ -1250,7 +1250,7 @@ static int config_parse_make_dirs(
if (r == 0)
return 0;
- r = specifier_printf(word, specifier_table, NULL, &d);
+ r = specifier_printf(word, PATH_MAX-1, specifier_table, NULL, &d);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to expand specifiers in MakeDirectories= parameter, ignoring: %s", word);