diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/frrlua.h | 11 | ||||
| -rw-r--r-- | lib/frrscript.c | 4 | ||||
| -rw-r--r-- | lib/zclient.c | 10 | ||||
| -rw-r--r-- | lib/zclient.h | 4 |
4 files changed, 22 insertions, 7 deletions
diff --git a/lib/frrlua.h b/lib/frrlua.h index 8e52931e50..6fb30938b0 100644 --- a/lib/frrlua.h +++ b/lib/frrlua.h @@ -35,6 +35,17 @@ extern "C" { #endif /* + * gcc-10 is complaining about the wrapper function + * not being compatible with lua_pushstring returning + * a char *. Let's wrapper it here to make our life + * easier + */ +static inline void lua_pushstring_wrapper(lua_State *L, const char *str) +{ + (void)lua_pushstring(L, str); +} + +/* * Converts a prefix to a Lua value and pushes it on the stack. */ void lua_pushprefix(lua_State *L, const struct prefix *prefix); diff --git a/lib/frrscript.c b/lib/frrscript.c index a3de474a4e..10d400886d 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -39,7 +39,7 @@ struct frrscript_codec frrscript_codecs_lib[] = { .encoder = (encoder_func)lua_pushintegerp, .decoder = lua_tointegerp}, {.typename = "string", - .encoder = (encoder_func)lua_pushstring, + .encoder = (encoder_func)lua_pushstring_wrapper, .decoder = lua_tostringp}, {.typename = "prefix", .encoder = (encoder_func)lua_pushprefix, @@ -208,7 +208,7 @@ struct frrscript *frrscript_load(const char *name, fs->L = luaL_newstate(); frrlua_export_logging(fs->L); - char fname[MAXPATHLEN]; + char fname[MAXPATHLEN * 2]; snprintf(fname, sizeof(fname), "%s/%s.lua", scriptdir, fs->name); int ret = luaL_loadfile(fs->L, fname); diff --git a/lib/zclient.c b/lib/zclient.c index f16c94369b..bfdf4971bb 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -996,7 +996,7 @@ done: return ret; } -int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) +static int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) { int i; @@ -1007,6 +1007,13 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) return -1; } + if (api_nhg->nexthop_num >= MULTIPATH_NUM || + api_nhg->backup_nexthop_num >= MULTIPATH_NUM) { + flog_err(EC_LIB_ZAPI_ENCODE, + "%s: zapi NHG encode with invalid input\n", __func__); + return -1; + } + stream_reset(s); zclient_create_header(s, cmd, VRF_DEFAULT); @@ -1024,7 +1031,6 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) zapi_nexthop_encode(s, &api_nhg->nexthops[i], 0, 0); /* Backup nexthops */ - stream_putw(s, api_nhg->backup_nexthop_num); for (i = 0; i < api_nhg->backup_nexthop_num; i++) diff --git a/lib/zclient.h b/lib/zclient.h index 57bad7c2e6..cf52ea91a0 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -1021,9 +1021,7 @@ bool zapi_ipset_notify_decode(struct stream *s, uint32_t *unique, enum zapi_ipset_notify_owner *note); - -extern int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg); -extern int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg); +/* Nexthop-group message apis */ extern enum zclient_send_status zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg); |
