summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-ip
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-02-08 11:00:54 +0100
committerJo-Philipp Wich <jo@mein.io>2020-02-08 11:03:56 +0100
commitc2eeb09bd99b03eead837d8dbfb3f0d8046ccc65 (patch)
tree64ba389ff4dcb035e262b94ff5e64a2058935815 /libs/luci-lib-ip
parentfaabe9831251e6c08f3870331ed01d16e3fc30d1 (diff)
luci-lib-ip: explicitly clear scope when allocating new userdata
Fixes: #3609 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'libs/luci-lib-ip')
-rw-r--r--libs/luci-lib-ip/src/ip.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libs/luci-lib-ip/src/ip.c b/libs/luci-lib-ip/src/ip.c
index 698cf9a11f..10d11a365b 100644
--- a/libs/luci-lib-ip/src/ip.c
+++ b/libs/luci-lib-ip/src/ip.c
@@ -747,6 +747,7 @@ static int cidr_mask(lua_State *L)
if (!(p2 = lua_newuserdata(L, sizeof(*p2))))
return 0;
+ p2->scope = 0;
p2->bits = AF_BITS(p1->family);
p2->family = p1->family;
@@ -790,6 +791,7 @@ static int cidr_mapped4(lua_State *L)
if (!(p2 = lua_newuserdata(L, sizeof(*p2))))
return 0;
+ p2->scope = 0;
p2->family = AF_INET;
p2->bits = (p1->bits > AF_BITS(AF_INET)) ? AF_BITS(AF_INET) : p1->bits;
memcpy(&p2->addr.v4, p1->addr.v6.s6_addr + 12, sizeof(p2->addr.v4));
@@ -830,6 +832,7 @@ static int cidr_tolinklocal(lua_State *L)
if (!(p2 = lua_newuserdata(L, sizeof(*p2))))
return 0;
+ p2->scope = p1->scope;
p2->family = AF_INET6;
p2->bits = AF_BITS(AF_INET6);
p2->addr.u8[0] = 0xFE;
@@ -870,6 +873,7 @@ static int cidr_tomac(lua_State *L)
if (!(p2 = lua_newuserdata(L, sizeof(*p2))))
return 0;
+ p2->scope = 0;
p2->family = AF_PACKET;
p2->bits = AF_BITS(AF_PACKET);
p2->addr.u8[0] = p1->addr.u8[8] ^ 0x02;