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

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

 



When setting NFTNL_EXPR_EXTHDR_TYPE, one needs to call
nftnl_expr_set_u8() and not nftnl_expr_set_u32(). Otherwise 'type'
variable is assigned to uint32_t parameter before being passed to
nftnl_expr_exthdr_set() as void pointer which casts it to uint8_t.
On big endian systems, the latter would only consider the most
significant byte instead of the least significant one.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 src/expr/exthdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c
index 75cafbc113f73..a3518353be09a 100644
--- a/src/expr/exthdr.c
+++ b/src/expr/exthdr.c
@@ -270,7 +270,7 @@ nftnl_expr_exthdr_json_parse(struct nftnl_expr *e, json_t *root,
 		type = str2exthdr_type(exthdr_type);
 		if (type < 0)
 			return -1;
-		nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_TYPE, type);
+		nftnl_expr_set_u8(e, NFTNL_EXPR_EXTHDR_TYPE, type);
 	}
 
 	if (nftnl_jansson_parse_val(root, "offset", NFTNL_TYPE_U32, &uval32,
-- 
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