]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
expr: ct: Delete the last comma character in json text
authorAna Rey <anarey@gmail.com>
Tue, 24 Jun 2014 06:46:39 +0000 (08:46 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 24 Jun 2014 08:36:21 +0000 (10:36 +0200)
Code refactoring to delete correctly the last comma character in json text.

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/expr/ct.c

index 2c28beb2d699486b140278f534c62cf8a3e82297..caabdbce20501128dd6bd7ed7c3dfe7ef4237485 100644 (file)
@@ -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