From: Ana Rey Date: Tue, 24 Jun 2014 06:46:39 +0000 (+0200) Subject: expr: ct: Delete the last comma character in json text X-Git-Tag: libnftnl-1.0.2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe8ba5890b9eeca889298b59de75c47db7b4ae89;p=thirdparty%2Flibnftnl.git expr: ct: Delete the last comma character in json text Code refactoring to delete correctly the last comma character in json text. Signed-off-by: Ana Rey Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/expr/ct.c b/src/expr/ct.c index 2c28beb2..caabdbce 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -358,9 +358,10 @@ nft_expr_ct_snprintf_json(char *buf, size_t size, struct nft_rule_expr *e) } /* Remove the last separator characther */ - buf[offset-1] = '\0'; + if (offset > 0) + offset--; - return offset-1; + return offset; } static int