]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip-link: Fix use after free in nl_get_ll_addr_len()
authorPhil Sutter <phil@nwl.cc>
Thu, 1 Mar 2018 09:35:12 +0000 (10:35 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 2 Mar 2018 21:29:40 +0000 (13:29 -0800)
Immediately after freeing the buffer returned from rtnl_talk(), it is
accessed again via pointer in struct rtattr array. This leads to some
builds not allowing to set an interface's MAC address because the
expected length value is garbage.

Fixes: 86bf43c7c2fdc ("lib/libnetlink: update rtnl_talk to support malloc buff at run time")
Signed-off-by: Phil Sutter <phil@nwl.cc>
ip/iplink.c

index 230f4c5377d9fee8e34a7c625aef536b72455201..d401311bcad9f2db4f4e867abb448c1455f1a44d 100644 (file)
@@ -276,8 +276,9 @@ static int nl_get_ll_addr_len(unsigned int dev_index)
                return -1;
        }
 
+       len = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
        free(answer);
-       return RTA_PAYLOAD(tb[IFLA_ADDRESS]);
+       return len;
 }
 
 static void iplink_parse_vf_vlan_info(int vf, int *argcp, char ***argvp,