diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-10 01:46:48 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-12 10:26:07 +0900 |
commit | 065364920281e1cf59cab989e17aff21790505c4 (patch) | |
tree | eb7c2c1045de0b868d706a1b68d6d3e4e0aac394 /src/test/test-specifier.c | |
parent | 678d6b4f9280cb0dcee50d5011dd9b904a42ed6a (diff) | |
download | systemd-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/test/test-specifier.c')
-rw-r--r-- | src/test/test-specifier.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/test-specifier.c b/src/test/test-specifier.c index cad4aa56ec..e9d501955c 100644 --- a/src/test/test-specifier.c +++ b/src/test/test-specifier.c @@ -69,7 +69,7 @@ static void test_specifier_printf(void) { log_info("/* %s */", __func__); - r = specifier_printf("xxx a=%X b=%Y yyy", table, NULL, &w); + r = specifier_printf("xxx a=%X b=%Y yyy", SIZE_MAX, table, NULL, &w); assert_se(r >= 0); assert_se(w); @@ -77,13 +77,13 @@ static void test_specifier_printf(void) { assert_se(streq(w, "xxx a=AAAA b=BBBB yyy")); free(w); - r = specifier_printf("machine=%m, boot=%b, host=%H, version=%v, arch=%a", table, NULL, &w); + r = specifier_printf("machine=%m, boot=%b, host=%H, version=%v, arch=%a", SIZE_MAX, table, NULL, &w); assert_se(r >= 0); assert_se(w); puts(w); w = mfree(w); - specifier_printf("os=%o, os-version=%w, build=%B, variant=%W", table, NULL, &w); + specifier_printf("os=%o, os-version=%w, build=%B, variant=%W", SIZE_MAX, table, NULL, &w); if (w) puts(w); } @@ -97,7 +97,7 @@ static void test_specifiers(void) { xsprintf(spec, "%%%c", s->specifier); - assert_se(specifier_printf(spec, specifier_table, NULL, &resolved) >= 0); + assert_se(specifier_printf(spec, SIZE_MAX, specifier_table, NULL, &resolved) >= 0); log_info("%%%c → %s", s->specifier, resolved); } |