aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/attr.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-11-28 06:05:19 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-28 06:05:19 -0500
commitea5693ccc553951ae44cb963b28cce85edc275c9 (patch)
tree44ca6da57e63035537d01cf58c24837067c2ec26 /net/netlink/attr.c
parented77a89c30fa03dcb234a84ddea710b3fb7b62da (diff)
netlink: allow empty nested attributes
validate_nla() currently doesn't allow empty nested attributes. This makes userspace code unnecessarily complicated when starting and ending the nested attribute is done by generic upper level code and the inner attributes are dumped by a module. Add a special case to accept empty nested attributes. When the nested attribute is non empty, the same checks as before are performed. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink/attr.c')
-rw-r--r--net/netlink/attr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/netlink/attr.c b/net/netlink/attr.c
index c83fea7da9a8..56c3ce7fe29a 100644
--- a/net/netlink/attr.c
+++ b/net/netlink/attr.c
@@ -83,6 +83,12 @@ static int validate_nla(struct nlattr *nla, int maxtype,
83 if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla)) 83 if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
84 return -ERANGE; 84 return -ERANGE;
85 break; 85 break;
86 case NLA_NESTED:
87 /* a nested attributes is allowed to be empty; if its not,
88 * it must have a size of at least NLA_HDRLEN.
89 */
90 if (attrlen == 0)
91 break;
86 default: 92 default:
87 if (pt->len) 93 if (pt->len)
88 minlen = pt->len; 94 minlen = pt->len;