diff options
author | Patrick McHardy <kaber@trash.net> | 2015-04-12 21:10:42 +0100 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2015-06-02 13:03:58 +0200 |
commit | 9c641885afea6f46b62f591ed9b0e3006fb23701 (patch) | |
tree | b6b6ab197b115e13d3ac3f81f24ace349af374b6 /src/netlink.c | |
parent | 1e4bf9dbb9218030ce9a5ee0b30eb33f918ca6bf (diff) |
netlink: pad constant concat sub-expressions
Pad all but the last sub-expressions of a concat expressions.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/netlink.c b/src/netlink.c index d31387f8..3369d223 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -273,23 +273,21 @@ static void netlink_gen_concat_data(const struct expr *expr, const struct expr *i; unsigned int len, offset; - len = 0; - list_for_each_entry(i, &expr->expressions, list) - len += i->len; - + len = expr->len / BITS_PER_BYTE; if (1) { - unsigned char data[len / BITS_PER_BYTE]; + unsigned char data[len]; + memset(data, 0, sizeof(data)); offset = 0; 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); - offset += i->len / BITS_PER_BYTE; + offset += netlink_padded_len(i->len) / BITS_PER_BYTE; } - memcpy(nld->value, data, len / BITS_PER_BYTE); - nld->len = len / BITS_PER_BYTE; + memcpy(nld->value, data, len); + nld->len = len; } } |