]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: floating point exception with concatenations
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 3 Apr 2018 11:03:39 +0000 (13:03 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 3 Apr 2018 11:22:44 +0000 (13:22 +0200)
If the length is less than 1 byte, this codepath hits a floating point
exception, use div_round_up() as everywhere else in the code.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink.c

index bfa30502a2b20d6e02cb09404e87a9d9e4cb6a44..00fac11d6156404abaf8ed6fdf33314e165ddcc2 100644 (file)
@@ -371,7 +371,7 @@ static void netlink_gen_concat_data(const struct expr *expr,
                list_for_each_entry(i, &expr->expressions, list) {
                        assert(i->ops->type == EXPR_VALUE);
                        mpz_export_data(data + offset, i->value, i->byteorder,
-                                       i->len / BITS_PER_BYTE);
+                                       div_round_up(i->len, BITS_PER_BYTE));
                        offset += netlink_padded_len(i->len) / BITS_PER_BYTE;
                }