From b588716468c4171d60cbdb4afd2e747a6fa394b1 Mon Sep 17 00:00:00 2001 From: Shuai Zhang Date: Thu, 27 Nov 2014 20:38:01 +0800 Subject: [PATCH] fix wrong nlmsg_len MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nlmsg_len is the length of message including header. Signed-off-by: Shuai Zhang Acked-by: Stéphane Graber --- src/lxc/nl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/nl.c b/src/lxc/nl.c index 7c0f1e53b..132a907f7 100644 --- a/src/lxc/nl.c +++ b/src/lxc/nl.c @@ -107,14 +107,14 @@ void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr) extern struct nlmsg *nlmsg_alloc(size_t size) { struct nlmsg *nlmsg; - size_t len = NLMSG_ALIGN(size) + NLMSG_ALIGN(sizeof(struct nlmsghdr *)); + size_t len = NLMSG_HDRLEN + NLMSG_ALIGN(size); nlmsg = (struct nlmsg *)malloc(len); if (!nlmsg) return NULL; memset(nlmsg, 0, len); - nlmsg->nlmsghdr.nlmsg_len = NLMSG_ALIGN(size); + nlmsg->nlmsghdr.nlmsg_len = NLMSG_HDRLEN; return nlmsg; }