]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Wrong calcultation in nla_reserve
authorEmmanuel Thierry <emmanuel.thierry@telecom-bretagne.eu>
Wed, 24 Apr 2013 16:39:19 +0000 (18:39 +0200)
committerThomas Graf <tgraf@suug.ch>
Sun, 28 Apr 2013 08:34:50 +0000 (10:34 +0200)
There seams to be an error in the calculation of needed space for the message in nla_reserve. The current size of the message is counted twice: Once in NLMSG_ALIGN, once in the condition below.
This causes nla_put_* calls to be rejected if the allocation size of the message has been strictly calculated by the caller.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/attr.c

index 6fc6af55c26ba26ef4fd802dbcd3b120d87b5f71..535f10ca2bd4685e6aee60f3f3a9b8df1e54e203 100644 (file)
@@ -464,7 +464,7 @@ struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen)
        
        tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
 
-       if ((tlen + msg->nm_nlh->nlmsg_len) > msg->nm_size)
+       if (tlen > msg->nm_size)
                return NULL;
 
        nla = (struct nlattr *) nlmsg_tail(msg->nm_nlh);