summaryrefslogtreecommitdiff
path: root/src/core/unit-printf.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-05-10 01:46:48 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-05-12 10:26:07 +0900
commit065364920281e1cf59cab989e17aff21790505c4 (patch)
treeeb7c2c1045de0b868d706a1b68d6d3e4e0aac394 /src/core/unit-printf.c
parent678d6b4f9280cb0dcee50d5011dd9b904a42ed6a (diff)
downloadsystemd-065364920281e1cf59cab989e17aff21790505c4.tar.gz
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/core/unit-printf.c')
-rw-r--r--src/core/unit-printf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index 8e50a81b97..ee8b0b3de8 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -201,10 +201,10 @@ int unit_name_printf(const Unit *u, const char* format, char **ret) {
assert(format);
assert(ret);
- return specifier_printf(format, table, u, ret);
+ return specifier_printf(format, UNIT_NAME_MAX, table, u, ret);
}
-int unit_full_printf(const Unit *u, const char *format, char **ret) {
+int unit_full_printf_full(const Unit *u, const char *format, size_t max_length, char **ret) {
/* This is similar to unit_name_printf() but also supports unescaping. Also, adds a couple of additional codes
* (which are likely not suitable for unescaped inclusion in unit names):
*
@@ -265,5 +265,5 @@ int unit_full_printf(const Unit *u, const char *format, char **ret) {
{}
};
- return specifier_printf(format, table, u, ret);
+ return specifier_printf(format, max_length, table, u, ret);
}