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.
This commit is contained in:
Yu Watanabe
2021-05-12 10:26:07 +09:00
parent 678d6b4f92
commit 0653649202
15 changed files with 113 additions and 88 deletions
+2 -2
View File
@@ -103,7 +103,7 @@ static int specifier_last_component(char specifier, const void *data, const void
return 0;
}
int install_full_printf(const UnitFileInstallInfo *i, const char *format, char **ret) {
int install_full_printf_internal(const UnitFileInstallInfo *i, const char *format, size_t max_length, char **ret) {
/* This is similar to unit_name_printf() */
const Specifier table[] = {
@@ -123,5 +123,5 @@ int install_full_printf(const UnitFileInstallInfo *i, const char *format, char *
assert(format);
assert(ret);
return specifier_printf(format, table, i, ret);
return specifier_printf(format, max_length, table, i, ret);
}