diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-28 13:23:24 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-28 13:23:24 +0100 |
commit | 65f0135491112341fc3af8559537eab85aa47e18 (patch) | |
tree | 2d42f2d35a093cae7a9926266ecd885384e921b2 /libs/luci-lib-ip/src/ip.c | |
parent | 44a62295f9fbf68ac47d3f3625d9cba6e9842757 (diff) |
luci-lib-ip: multiple fixes
* Fix broken neighbor filtering by address range due to uninitialized memory
* Fix wrong sizeof in _cidr_add_sub when adding/substracing IPv6 addresses
* Properly convert numeric values to IPv6 addresses
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'libs/luci-lib-ip/src/ip.c')
-rw-r--r-- | libs/luci-lib-ip/src/ip.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/luci-lib-ip/src/ip.c b/libs/luci-lib-ip/src/ip.c index 8c9155b1ae..595ac8c3a5 100644 --- a/libs/luci-lib-ip/src/ip.c +++ b/libs/luci-lib-ip/src/ip.c @@ -299,10 +299,10 @@ static int _cidr_new(lua_State *L, int index, int family, bool mask) cidr.family = AF_INET6; cidr.bits = 128; cidr.len = sizeof(cidr.addr.v6); - cidr.addr.v6.s6_addr[15] = n; - cidr.addr.v6.s6_addr[14] = (n >> 8); - cidr.addr.v6.s6_addr[13] = (n >> 16); - cidr.addr.v6.s6_addr[12] = (n >> 24); + cidr.addr.v6.s6_addr[12] = n; + cidr.addr.v6.s6_addr[13] = (n >> 8); + cidr.addr.v6.s6_addr[14] = (n >> 16); + cidr.addr.v6.s6_addr[15] = (n >> 24); } else { @@ -586,7 +586,7 @@ static int _cidr_add_sub(lua_State *L, bool add) { if (p1->family == AF_INET6) { - for (i = 0, carry = 0; i < sizeof(r); i++) + for (i = 0, carry = 0; i < sizeof(r.addr.v6.s6_addr); i++) { if (add) { @@ -1123,7 +1123,7 @@ out: static int neighbor_dump(lua_State *L) { - cidr_t p; + cidr_t p = { }; const char *s; struct ether_addr *mac; struct dump_filter filter = { .type = 0xFF & ~NUD_NOARP }; |