Skip to contentSkip to conversation

payload: fix endianess issue in payload_expr_pctx_update()

PATCH In review Pablo Neira Ayuso 2 participants 3 messages Dec 4, 2014 – Dec 5, 2014 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH v2 1/1 payload: fix endianess issue in payload_expr_pctx_update()

Use constant_data_ptr() to point to the right memory position on big endian when exporting data that is stored in a larger variable.

---
v2: this also fixes the printing of 1 byte fields that are converted to
symbolic constant.

 src/datatype.c |    4 ++--
 src/payload.c  |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
src/datatype.c +2 -2
index fd3573e..729e63b 100644
@@ -158,8 +158,8 @@ void symbolic_constant_print(const struct symbol_table *tbl,
 
 	/* Export the data in the correct byteorder for comparison */
 	assert(expr->len / BITS_PER_BYTE <= sizeof(val));
-	mpz_export_data(&val, expr->value, expr->byteorder,
-			expr->len / BITS_PER_BYTE);
+	mpz_export_data(constant_data_ptr(val, expr->len), expr->value,
+			expr->byteorder, expr->len / BITS_PER_BYTE);
 
 	for (s = tbl->symbols; s->identifier != NULL; s++) {
 		if (val == s->value)
src/payload.c +2 -2
index ebf8079..83742fb 100644
@@ -79,8 +79,8 @@ static void payload_expr_pctx_update(struct proto_ctx *ctx,
 
 	/* Export the data in the correct byte order */
 	assert(right->len / BITS_PER_BYTE <= sizeof(proto));
-	mpz_export_data(&proto, right->value, right->byteorder,
-			right->len / BITS_PER_BYTE);
+	mpz_export_data(constant_data_ptr(proto, right->len), right->value,
+			right->byteorder, right->len / BITS_PER_BYTE);
 
 	base = ctx->protocol[left->payload.base].desc;
 	desc = proto_find_upper(base, proto);
Signature · 1 line
1.7.10.4
Tested-by on v2 1/1
#1 lore raw
Quoted 32 lines · Pablo Neira Ayuso

Use constant_data_ptr() to point to the right memory position on big endian when exporting data that is stored in a larger variable.

---
v2: this also fixes the printing of 1 byte fields that are converted to
symbolic constant.

  src/datatype.c |    4 ++--
  src/payload.c  |    4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)
src/datatype.c +2 -2
index fd3573e..729e63b 100644
@@ -158,8 +158,8 @@ void symbolic_constant_print(const struct symbol_table *tbl,
 
  	/* Export the data in the correct byteorder for comparison */
  	assert(expr->len / BITS_PER_BYTE <= sizeof(val));
-	mpz_export_data(&val, expr->value, expr->byteorder,
-			expr->len / BITS_PER_BYTE);
+	mpz_export_data(constant_data_ptr(val, expr->len), expr->value,
+			expr->byteorder, expr->len / BITS_PER_BYTE);
 
  	for (s = tbl->symbols; s->identifier != NULL; s++) {
  		if (val == s->value)
src/payload.c +0 -0
index ebf8079..83742fb 100644

src/payload.c static void payload_expr_pctx_update(struct proto_ctx *ctx, · line 86

Quoted 10 lines
src/payload.c +2 -2
@@ -79,8 +79,8 @@ static void payload_expr_pctx_update(struct proto_ctx *ctx,
 
  	/* Export the data in the correct byte order */
  	assert(right->len / BITS_PER_BYTE <= sizeof(proto));
-	mpz_export_data(&proto, right->value, right->byteorder,
-			right->len / BITS_PER_BYTE);
+	mpz_export_data(constant_data_ptr(proto, right->len), right->value,
+			right->byteorder, right->len / BITS_PER_BYTE);
 
  	base = ctx->protocol[left->payload.base].desc;
  	desc = proto_find_upper(base, proto);

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