Patchwork [libnftables,06/13] json: bitwise: add missing node len

login
register
mail settings
Submitter Alvaro Neira
Date Aug. 9, 2013, 11:13 a.m.
Message ID <20130809111300.29819.10398.stgit@Ph0enix>
Download mbox | patch
Permalink /patch/265996/
State Accepted
Headers show

Comments

Alvaro Neira - Aug. 9, 2013, 11:13 a.m.
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>

I have added the len node in bitwise which was missing

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
 src/expr/bitwise.c  |    5 +++--
 src/expr/data_reg.c |    4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)


--
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

Patch

diff --git a/src/expr/bitwise.c b/src/expr/bitwise.c
index edc5a39..6c86acb 100644
--- a/src/expr/bitwise.c
+++ b/src/expr/bitwise.c
@@ -238,8 +238,9 @@  nft_rule_expr_bitwise_snprintf_json(char *buf, size_t size,
 	int len = size, offset = 0, ret;
 
 	ret = snprintf(buf, len, "\"sreg\" : %u, "
-				"\"dreg\" : %u, ",
-		       bitwise->sreg, bitwise->dreg);
+				"\"dreg\" : %u, "
+				"\"len\" : %u, ",
+		       bitwise->sreg, bitwise->dreg, bitwise->len);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	ret = snprintf(buf+offset, len, "\"mask\" : {");
diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index 825e474..4c354ef 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -250,10 +250,10 @@  nft_data_reg_value_snprintf_json(char *buf, size_t size,
 			SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 		}
 
-		ret = snprintf(buf+offset, len, "\"");
+		ret = snprintf(buf+offset, len, "\", ");
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
-
+	offset -= 2;
 	ret = snprintf(buf+offset, len, "}");
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);