Commit b5887164 by Shuai Zhang Committed by Stéphane Graber

fix wrong nlmsg_len

nlmsg_len is the length of message including header. Signed-off-by: 's avatarShuai Zhang <zs.broccoli@gmail.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent a6ee1277
...@@ -107,14 +107,14 @@ void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr) ...@@ -107,14 +107,14 @@ void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr)
extern struct nlmsg *nlmsg_alloc(size_t size) extern struct nlmsg *nlmsg_alloc(size_t size)
{ {
struct nlmsg *nlmsg; 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); nlmsg = (struct nlmsg *)malloc(len);
if (!nlmsg) if (!nlmsg)
return NULL; return NULL;
memset(nlmsg, 0, len); memset(nlmsg, 0, len);
nlmsg->nlmsghdr.nlmsg_len = NLMSG_ALIGN(size); nlmsg->nlmsghdr.nlmsg_len = NLMSG_HDRLEN;
return nlmsg; return nlmsg;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment