All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft] datatype: avoid crash in debug mode when printing integers
@ 2015-06-26  8:50 Florian Westphal
  2015-06-30  0:07 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2015-06-26  8:50 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

nft -i --debug=all
nft> add rule ip filter foo mark 42

dies with sigfpe; seems mpz doesn't like len 0:
#1  0x0805f2ee in mpz_export_data (data=0xbfeda588, op=0x9d9fb08, byteorder=BYTEORDER_HOST_ENDIAN, len=0) at gmputil.c:115

After patch this prints 0x0000002a.
---
 src/datatype.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/datatype.c b/src/datatype.c
index f42e3df..f79f5d2 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -156,13 +156,14 @@ out:
 void symbolic_constant_print(const struct symbol_table *tbl,
 			     const struct expr *expr)
 {
+	unsigned int len = div_round_up(expr->len, BITS_PER_BYTE);
 	const struct symbolic_constant *s;
 	uint64_t val = 0;
 
 	/* Export the data in the correct byteorder for comparison */
 	assert(expr->len / BITS_PER_BYTE <= sizeof(val));
 	mpz_export_data(constant_data_ptr(val, expr->len), expr->value,
-			expr->byteorder, expr->len / BITS_PER_BYTE);
+			expr->byteorder, len);
 
 	for (s = tbl->symbols; s->identifier != NULL; s++) {
 		if (val == s->value)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nft] datatype: avoid crash in debug mode when printing integers
  2015-06-26  8:50 [PATCH nft] datatype: avoid crash in debug mode when printing integers Florian Westphal
@ 2015-06-30  0:07 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-30  0:07 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

On Fri, Jun 26, 2015 at 10:50:44AM +0200, Florian Westphal wrote:
> nft -i --debug=all
> nft> add rule ip filter foo mark 42
> 
> dies with sigfpe; seems mpz doesn't like len 0:
> #1  0x0805f2ee in mpz_export_data (data=0xbfeda588, op=0x9d9fb08, byteorder=BYTEORDER_HOST_ENDIAN, len=0) at gmputil.c:115
> 
> After patch this prints 0x0000002a.

I have pushed this to nft. Thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-30  0:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26  8:50 [PATCH nft] datatype: avoid crash in debug mode when printing integers Florian Westphal
2015-06-30  0:07 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.