From 5898ce6f35e1a2fa58fcae1dea5fb1eb808d44cf Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Mon, 4 Jan 2021 12:50:19 -0500 Subject: libs,zebra: remove zapi nhg encode and decode public apis The raw zapi apis to encode and decode NHGs don't need to be public; also add a little more validity-checking. Signed-off-by: Mark Stapp --- lib/zclient.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/zclient.c') 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++) -- cgit v1.2.3