aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-08-26 23:13:18 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:18:25 -0400
commit5176f91ea83f1a59eba4dba88634a4729d51d1ac (patch)
tree80b35d2cd7ab316f0ee96ab742fee5073b949130 /net/core
parenta5531a5d852008be40811496029012f4ad3093d1 (diff)
[NETLINK]: Make use of NLA_STRING/NLA_NUL_STRING attribute validation
Converts existing NLA_STRING attributes to use the new validation features, saving a couple of temporary buffers. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/fib_rules.c8
-rw-r--r--net/core/rtnetlink.c9
2 files changed, 5 insertions, 12 deletions
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 7b2e9bb1a605..a99d87d82b7f 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -161,9 +161,6 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
161 if (err < 0) 161 if (err < 0)
162 goto errout; 162 goto errout;
163 163
164 if (tb[FRA_IFNAME] && nla_len(tb[FRA_IFNAME]) > IFNAMSIZ)
165 goto errout;
166
167 rule = kzalloc(ops->rule_size, GFP_KERNEL); 164 rule = kzalloc(ops->rule_size, GFP_KERNEL);
168 if (rule == NULL) { 165 if (rule == NULL) {
169 err = -ENOMEM; 166 err = -ENOMEM;
@@ -177,10 +174,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
177 struct net_device *dev; 174 struct net_device *dev;
178 175
179 rule->ifindex = -1; 176 rule->ifindex = -1;
180 if (nla_strlcpy(rule->ifname, tb[FRA_IFNAME], 177 nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ);
181 IFNAMSIZ) >= IFNAMSIZ)
182 goto errout_free;
183
184 dev = __dev_get_by_name(rule->ifname); 178 dev = __dev_get_by_name(rule->ifname);
185 if (dev) 179 if (dev)
186 rule->ifindex = dev->ifindex; 180 rule->ifindex = dev->ifindex;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 8f225499e32e..0ebcf8488e99 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -371,8 +371,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
371} 371}
372 372
373static struct nla_policy ifla_policy[IFLA_MAX+1] __read_mostly = { 373static struct nla_policy ifla_policy[IFLA_MAX+1] __read_mostly = {
374 [IFLA_IFNAME] = { .type = NLA_STRING }, 374 [IFLA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ-1 },
375 [IFLA_MAP] = { .minlen = sizeof(struct rtnl_link_ifmap) }, 375 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
376 [IFLA_MTU] = { .type = NLA_U32 }, 376 [IFLA_MTU] = { .type = NLA_U32 },
377 [IFLA_TXQLEN] = { .type = NLA_U32 }, 377 [IFLA_TXQLEN] = { .type = NLA_U32 },
378 [IFLA_WEIGHT] = { .type = NLA_U32 }, 378 [IFLA_WEIGHT] = { .type = NLA_U32 },
@@ -392,9 +392,8 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
392 if (err < 0) 392 if (err < 0)
393 goto errout; 393 goto errout;
394 394
395 if (tb[IFLA_IFNAME] && 395 if (tb[IFLA_IFNAME])
396 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ) >= IFNAMSIZ) 396 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
397 return -EINVAL;
398 397
399 err = -EINVAL; 398 err = -EINVAL;
400 ifm = nlmsg_data(nlh); 399 ifm = nlmsg_data(nlh);