diff mbox

[libnftables,v2,1/2] rule: json: Fixed wrong offset return

Message ID 20130924125410.18650.33470.stgit@Ph0enix
State Accepted
Headers show

Commit Message

Alvaro Neira Sept. 24, 2013, 12:54 p.m. UTC
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>

I have fixed the offset because when i try to print more of one rule,
the json output support only print one rule because this function return
a wrong offset value

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
 src/rule.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pablo Neira Ayuso Sept. 25, 2013, 8:11 p.m. UTC | #1
On Tue, Sep 24, 2013 at 02:54:10PM +0200, Alvaro Neira wrote:
> From: Álvaro Neira Ayuso <alvaroneay@gmail.com>
> 
> I have fixed the offset because when i try to print more of one rule,
> the json output support only print one rule because this function return
> a wrong offset value

Mangled and applied a similar, but better solution for this.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/rule.c b/src/rule.c
index e744cf8..e593109 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -748,7 +748,7 @@  static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r,
 	ret = snprintf(buf+offset-1, len, "]}}");
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
-	return offset;
+	return offset-1;
 }
 
 static int nft_rule_snprintf_xml(char *buf, size_t size, struct nft_rule *r,