netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: leroy christophe <christophe.leroy@c-s.fr>
To: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: Re: [PATCH nft v2] payload: fix endianess issue in payload_expr_pctx_update()
Date: Fri, 05 Dec 2014 07:39:23 +0100	[thread overview]
Message-ID: <5481531B.9090105@c-s.fr> (raw)
In-Reply-To: <1417700189-11337-1-git-send-email-pablo@netfilter.org>

Tested-by: Christophe Leroy <christophe.leroy@c-s.fr>

Le 04/12/2014 14:36, Pablo Neira Ayuso a écrit :
> Use constant_data_ptr() to point to the right memory position on
> big endian when exporting data that is stored in a larger variable.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> 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(-)
>
> diff --git a/src/datatype.c b/src/datatype.c
> index fd3573e..729e63b 100644
> --- a/src/datatype.c
> +++ b/src/datatype.c
> @@ -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)
> diff --git a/src/payload.c b/src/payload.c
> index ebf8079..83742fb 100644
> --- a/src/payload.c
> +++ b/src/payload.c
> @@ -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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-12-05  6:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04 13:36 [PATCH nft v2] payload: fix endianess issue in payload_expr_pctx_update() Pablo Neira Ayuso
2014-12-05  6:39 ` leroy christophe [this message]
2014-12-05 10:44   ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5481531B.9090105@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).