diff options
author | Tom Herbert <tom@herbertland.com> | 2016-08-15 16:30:22 -0700 |
---|---|---|
committer | Stephen Hemminger <sthemmin@microsoft.com> | 2016-08-17 13:51:18 -0700 |
commit | 2d01b393f4fcb005586b74741da70ffbe5f77970 (patch) | |
tree | 22a7e844617ed5c1c7adfea0b3e080a580bb1e9b | |
parent | 7e33b093318cd9281e3df3572ed64b57e12ba642 (diff) |
ipila: Fixed unitialized variables
Initialize locator and locator_match to zero and only do
addattr if they have been set.
Signed-off-by: Tom Herbert <tom@herbertland.com>
-rw-r--r-- | ip/ipila.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -149,8 +149,8 @@ static int do_list(int argc, char **argv) static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n, bool adding) { - __u64 locator; - __u64 locator_match; + __u64 locator = 0; + __u64 locator_match = 0; int ifindex = 0; bool loc_set = false; bool loc_match_set = false; @@ -202,8 +202,11 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n, } } - addattr64(n, 1024, ILA_ATTR_LOCATOR_MATCH, locator_match); - addattr64(n, 1024, ILA_ATTR_LOCATOR, locator); + if (loc_match_set) + addattr64(n, 1024, ILA_ATTR_LOCATOR_MATCH, locator_match); + + if (loc_set) + addattr64(n, 1024, ILA_ATTR_LOCATOR, locator); if (ifindex_set) addattr32(n, 1024, ILA_ATTR_IFINDEX, ifindex); |