diff options
| author | Johannes Berg <johannes.berg@intel.com> | 2019-04-26 08:07:27 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2019-04-27 17:07:21 -0400 |
| commit | 6f455f5f4e9c28aefaefbe18ce7304b499645d75 (patch) | |
| tree | f28d52c28e15bb7bf9cb4b58ab57d6b1aae2a769 /lib | |
| parent | f6ad55a6a184ebdf3d98a90eab0895f73ce9797e (diff) | |
netlink: add NLA_MIN_LEN
Rather than using NLA_UNSPEC for this type of thing, use NLA_MIN_LEN
so we can make NLA_UNSPEC be NLA_REJECT under certain conditions for
future attributes.
While at it, also use NLA_EXACT_LEN for the struct example.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nlattr.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/nlattr.c b/lib/nlattr.c index d26de6156b97..465c9e8ef8a5 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c | |||
| @@ -278,10 +278,17 @@ static int validate_nla(const struct nlattr *nla, int maxtype, | |||
| 278 | } | 278 | } |
| 279 | } | 279 | } |
| 280 | break; | 280 | break; |
| 281 | |||
| 282 | case NLA_UNSPEC: | ||
| 283 | case NLA_MIN_LEN: | ||
| 284 | if (attrlen < pt->len) | ||
| 285 | goto out_err; | ||
| 286 | break; | ||
| 287 | |||
| 281 | default: | 288 | default: |
| 282 | if (pt->len) | 289 | if (pt->len) |
| 283 | minlen = pt->len; | 290 | minlen = pt->len; |
| 284 | else if (pt->type != NLA_UNSPEC) | 291 | else |
| 285 | minlen = nla_attr_minlen[pt->type]; | 292 | minlen = nla_attr_minlen[pt->type]; |
| 286 | 293 | ||
| 287 | if (attrlen < minlen) | 294 | if (attrlen < minlen) |
