datatype: avoid crash in debug mode when printing integers
Florian Westphal
maintainerPATCH 1/1 datatype: avoid crash in debug mode when printing integers
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(-)
src/datatype.c +2 -1
@@ -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)
Signature · 1 line
2.1.0
Pablo Neira Ayuso
maintainerQuoted 7 lines · Florian Westphal
nft -i --debug=all
nft> add rule ip filter foo mark 42dies with sigfpe; seems mpz doesn't like len 0:
#10x0805f2eeinmpz_export_data(data=0xbfeda588, op=0x9d9fb08, byteorder=BYTEORDER_HOST_ENDIAN, len=0) at gmputil.c:115After patch this prints
0x0000002a.
I have pushed this to nft. Thanks.