diff options
author | Alvaro Neira Ayuso <alvaroneay@gmail.com> | 2013-09-25 22:06:34 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-09-25 22:06:34 +0200 |
commit | e7c068d131cc8e51aca6326f568b2333bf2076af (patch) | |
tree | 3938ab75f35b092216514eda74b069c3cd6b3f5e /src/rule.c | |
parent | 328e42bdf55a9f243b7c4a87cc98cda8b9fe6468 (diff) |
rule: json: fix returned string length
It was returning one byte more than the real string length.
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -745,7 +745,9 @@ static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r, SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - ret = snprintf(buf+offset-1, len, "]}}"); + /* Remove comma from last element */ + offset--; + ret = snprintf(buf+offset, len, "]}}"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); return offset; |