diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-01-27 08:00:11 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-02-01 17:21:39 -0500 |
commit | 5ffa8c818120e35c89becd938d160235c069dd12 (patch) | |
tree | e4a1ce20a003e23618bd54f49cb4acf68aed70cd /src/libsystemd/sd-bus/bus-control.c | |
parent | 294929f8916ca37d89ccb1757868d22f8068c56b (diff) |
Add a snprinf wrapper which checks that the buffer was big enough
If we scale our buffer to be wide enough for the format string, we
should expect that the calculation was correct.
char_array_0() invocations are removed, since snprintf nul-terminates
the output in any case.
A similar wrapper is used for strftime calls, but only in timedatectl.c.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-control.c')
-rw-r--r-- | src/libsystemd/sd-bus/bus-control.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index babfed8c2e..8d12c258f7 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -1268,7 +1268,7 @@ int bus_add_match_internal_kernel( if (c->type - BUS_MATCH_ARG < 3) name_change_arg[c->type - BUS_MATCH_ARG] = c->value_str; - snprintf(buf, sizeof(buf), "arg%i", c->type - BUS_MATCH_ARG); + xsprintf(buf, "arg%i", c->type - BUS_MATCH_ARG); bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str); using_bloom = true; break; @@ -1277,7 +1277,7 @@ int bus_add_match_internal_kernel( case BUS_MATCH_ARG_PATH...BUS_MATCH_ARG_PATH_LAST: { char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")]; - snprintf(buf, sizeof(buf), "arg%i-slash-prefix", c->type - BUS_MATCH_ARG_PATH); + xsprintf(buf, "arg%i-slash-prefix", c->type - BUS_MATCH_ARG_PATH); bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str); using_bloom = true; break; @@ -1286,7 +1286,7 @@ int bus_add_match_internal_kernel( case BUS_MATCH_ARG_NAMESPACE...BUS_MATCH_ARG_NAMESPACE_LAST: { char buf[sizeof("arg")-1 + 2 + sizeof("-dot-prefix")]; - snprintf(buf, sizeof(buf), "arg%i-dot-prefix", c->type - BUS_MATCH_ARG_NAMESPACE); + xsprintf(buf, "arg%i-dot-prefix", c->type - BUS_MATCH_ARG_NAMESPACE); bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str); using_bloom = true; break; |