]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/netlink/attr.c
[NETLINK]: attr: add nested compat attribute type
[net-next-2.6.git] / net / netlink / attr.c
index c591212793ee4d7cbd981cabe753a5825f68b4fc..e4d7bed99c2e8bbc763cef5fbb24a01a2ad91694 100644 (file)
@@ -72,6 +72,17 @@ static int validate_nla(struct nlattr *nla, int maxtype,
                        return -ERANGE;
                break;
 
+       case NLA_NESTED_COMPAT:
+               if (attrlen < pt->len)
+                       return -ERANGE;
+               if (attrlen < NLA_ALIGN(pt->len))
+                       break;
+               if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN)
+                       return -ERANGE;
+               nla = nla_data(nla) + NLA_ALIGN(pt->len);
+               if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
+                       return -ERANGE;
+               break;
        default:
                if (pt->len)
                        minlen = pt->len;