]> granicus.if.org Git - libnl/commitdiff
link: Modify link policy on the stack
authorThomas Graf <tgraf@suug.ch>
Tue, 5 Feb 2013 12:21:10 +0000 (13:21 +0100)
committerThomas Graf <tgraf@suug.ch>
Tue, 5 Feb 2013 12:21:10 +0000 (13:21 +0100)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/route/link.c

index 752f63a6bd694ed289f5aa7ac88be3f61d203457..26bd3dab7d9a8afa549fa9a9b21fd93ea9188494 100644 (file)
@@ -287,6 +287,9 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
        struct nlattr *tb[IFLA_MAX+1];
        struct rtnl_link_af_ops *af_ops = NULL;
        int err, family;
+       struct nla_policy real_link_policy[IFLA_MAX+1];
+
+       memcpy(&real_link_policy, link_policy, sizeof(link_policy));
 
        link = rtnl_link_alloc();
        if (link == NULL) {
@@ -311,7 +314,7 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
 
        if ((af_ops = af_lookup_and_alloc(link, family))) {
                if (af_ops->ao_protinfo_policy) {
-                       memcpy(&link_policy[IFLA_PROTINFO],
+                       memcpy(&real_link_policy[IFLA_PROTINFO],
                               af_ops->ao_protinfo_policy,
                               sizeof(struct nla_policy));
                }
@@ -319,7 +322,7 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
                link->l_af_ops = af_ops;
        }
 
-       err = nlmsg_parse(n, sizeof(*ifi), tb, IFLA_MAX, link_policy);
+       err = nlmsg_parse(n, sizeof(*ifi), tb, IFLA_MAX, real_link_policy);
        if (err < 0)
                goto errout;