]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Make sure we pop the table from the stack when decoding struct attr 10929/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 29 Mar 2022 14:47:28 +0000 (17:47 +0300)
committermergify-bot <noreply@mergify.com>
Wed, 30 Mar 2022 11:56:01 +0000 (11:56 +0000)
```
bgpd[81718]: bgpd/bgp_routemap.c:382: route_match_script(): assertion (lua_gettop(lfs->L) == 1) failed
BGP[81718]: Received signal 6 at 1648554165 (si_addr 0x6e00013f36, PC 0x7fcc5adebce1); aborting...
BGP[81718]: /usr/local/lib/libfrr.so.0(zlog_backtrace_sigsafe+0x5e) [0x7fcc5b1caf5e]
BGP[81718]: /usr/local/lib/libfrr.so.0(zlog_signal+0xe6) [0x7fcc5b1cb136]
BGP[81718]: /usr/local/lib/libfrr.so.0(+0xcd4b2) [0x7fcc5b1f54b2]
BGP[81718]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x14140) [0x7fcc5af89140]
BGP[81718]: /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x141) [0x7fcc5adebce1]
BGP[81718]: /lib/x86_64-linux-gnu/libc.so.6(abort+0x123) [0x7fcc5add5537]
BGP[81718]: /usr/local/lib/libfrr.so.0(_zlog_assert_failed+0xd7) [0x7fcc5b21ecd7]
BGP[81718]: /usr/lib/frr/bgpd(+0x162710) [0x55ed70255710]
BGP[81718]: /usr/local/lib/libfrr.so.0(+0xc0e47) [0x7fcc5b1e8e47]
BGP[81718]: /usr/local/lib/libfrr.so.0(route_map_apply_ext+0x4b6) [0x7fcc5b1eaaf6]
BGP[81718]: /usr/lib/frr/bgpd(+0x13eb24) [0x55ed70231b24]
BGP[81718]: /usr/lib/frr/bgpd(bgp_update+0x7db) [0x55ed7023f81b]
BGP[81718]: /usr/lib/frr/bgpd(bgp_nlri_parse_ip+0x113) [0x55ed70241bc3]
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 9aa2174c3990169e46b23b6e07cd87c145e364ed)

bgpd/bgp_script.c

index 9446a25a05c950b16235eb9dd0b77ebd7aa01ed8..bf3e612bfdb754f2feccd2486aed925342724475 100644 (file)
@@ -156,18 +156,19 @@ void lua_pushattr(lua_State *L, const struct attr *attr)
 
 void lua_decode_attr(lua_State *L, int idx, struct attr *attr)
 {
-       lua_getfield(L, -1, "metric");
+       lua_getfield(L, idx, "metric");
        attr->med = lua_tointeger(L, -1);
        lua_pop(L, 1);
-       lua_getfield(L, -1, "ifindex");
+       lua_getfield(L, idx, "ifindex");
        attr->nh_ifindex = lua_tointeger(L, -1);
        lua_pop(L, 1);
-       lua_getfield(L, -1, "aspath");
+       lua_getfield(L, idx, "aspath");
        attr->aspath = aspath_str2aspath(lua_tostring(L, -1));
        lua_pop(L, 1);
-       lua_getfield(L, -1, "localpref");
+       lua_getfield(L, idx, "localpref");
        attr->local_pref = lua_tointeger(L, -1);
        lua_pop(L, 1);
+       lua_pop(L, 1);
 }
 
 void *lua_toattr(lua_State *L, int idx)