aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/examples
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-03 19:07:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-03 19:08:20 +0200
commit41df6d23ed6816656d9655314dcf7735f1a7d3cc (patch)
treed6bede84505af0b13bd179e5ec06465dc74318a8 /contrib/examples
parentkeygen-html: add zip file example (diff)
downloadwireguard-monolithic-historical-41df6d23ed6816656d9655314dcf7735f1a7d3cc.tar.xz
wireguard-monolithic-historical-41df6d23ed6816656d9655314dcf7735f1a7d3cc.zip
embeddable-wg-library: zero attribute padding
See: http://git.netfilter.org/libmnl/commit/?id=37c876b55a2c00424ccda5a300ab5fdec1d88b22
Diffstat (limited to 'contrib/examples')
-rw-r--r--contrib/examples/embeddable-wg-library/wireguard.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/examples/embeddable-wg-library/wireguard.c b/contrib/examples/embeddable-wg-library/wireguard.c
index a713567..16ddd9a 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.c
+++ b/contrib/examples/embeddable-wg-library/wireguard.c
@@ -358,11 +358,15 @@ static void mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len,
{
struct nlattr *attr = mnl_nlmsg_get_payload_tail(nlh);
uint16_t payload_len = MNL_ALIGN(sizeof(struct nlattr)) + len;
+ int pad;
attr->nla_type = type;
attr->nla_len = payload_len;
memcpy(mnl_attr_get_payload(attr), data, len);
nlh->nlmsg_len += MNL_ALIGN(payload_len);
+ pad = MNL_ALIGN(len) - len;
+ if (pad > 0)
+ memset(mnl_attr_get_payload(attr) + len, 0, pad);
}
static void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data)