summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <alvaroneay@gmail.com>2013-09-25 22:06:34 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-09-25 22:06:34 +0200
commite7c068d131cc8e51aca6326f568b2333bf2076af (patch)
tree3938ab75f35b092216514eda74b069c3cd6b3f5e /src/rule.c
parent328e42bdf55a9f243b7c4a87cc98cda8b9fe6468 (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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rule.c b/src/rule.c
index b4ce8f1..5fd8814 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -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;