[libnftnl PATCH 2/3] expr/data_reg: Fix JSON parsing on big endian

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since reg->len is a 32bit variable, one needs to pass NFTNL_TYPE_U32 to
nftnl_jansson_parse_val(). Otherwise, only the most significant byte in
that variable is being written to.

Since the value could potentially be larger than 255, increase node_name
buffer to avoid a compiler warning.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 src/expr/data_reg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index 1b28b291617b8..ad7f4cb28ebd7 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -59,10 +59,10 @@ static int nftnl_data_reg_verdict_json_parse(union nftnl_data_reg *reg, json_t *
 static int nftnl_data_reg_value_json_parse(union nftnl_data_reg *reg, json_t *data,
 					 struct nftnl_parse_err *err)
 {
-	char node_name[8] = {};	/* strlen("data256") + 1 == 8 */
+	char node_name[32] = {};
 	int ret, remain = sizeof(node_name), offset = 0, i;
 
-	if (nftnl_jansson_parse_val(data, "len", NFTNL_TYPE_U8, &reg->len, err) < 0)
+	if (nftnl_jansson_parse_val(data, "len", NFTNL_TYPE_U32, &reg->len, err) < 0)
 			return DATA_NONE;
 
 	for (i = 0; i < div_round_up(reg->len, sizeof(uint32_t)); i++) {
-- 
2.17.0

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



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux