diff options
author | Arturo Borrero <arturo.borrero.glez@gmail.com> | 2013-09-26 00:13:08 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-09-27 16:02:08 +0200 |
commit | a54e60a541f009639d596e1fecaeeab67683d258 (patch) | |
tree | 213abd63d64d7e39e5e0d3e0f1f3cca3e8bc1a58 /src/expr | |
parent | 3e40a89d43db8cf6c5947baa7221e57e2b9cf351 (diff) |
src: snprintf: fix buffer lengths
Use 'len' instead of 'size' since we need the remaining unused bytes
in the buffer, not its total size.
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr')
-rw-r--r-- | src/expr/ct.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/expr/ct.c b/src/expr/ct.c index ccefa1b..bf18c7e 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -279,17 +279,17 @@ nft_expr_ct_snprintf_json(char *buf, size_t size, struct nft_rule_expr *e) int ret, len = size, offset = 0; struct nft_expr_ct *ct = nft_expr_data(e); - ret = snprintf(buf, size, "\"dreg\" : %u", ct->dreg); + ret = snprintf(buf, len, "\"dreg\" : %u", ct->dreg); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); if (e->flags & (1 << NFT_EXPR_CT_KEY)) { - ret = snprintf(buf+offset, size, ", \"key\" : \"%s\"", + ret = snprintf(buf+offset, len, ", \"key\" : \"%s\"", ctkey2str(ct->key)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } if (e->flags & (1 << NFT_EXPR_CT_DIR)) { - ret = snprintf(buf+offset, size, ", \"dir\" : %u", ct->dir); + ret = snprintf(buf+offset, len, ", \"dir\" : %u", ct->dir); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } |