From b900b3c6a4018415a385d76207489347cd629062 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 3 Jan 2020 19:07:25 -0500 Subject: lib: dont decode more nexthops than we can handle If someone provides us more nexthops than our configured multipath setting, drop the rest of them Signed-off-by: Quentin Young --- lib/zclient.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/zclient.c b/lib/zclient.c index 6982d287a..fd1b181e5 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -2679,6 +2679,17 @@ int zapi_labels_decode(struct stream *s, struct zapi_labels *zl) } STREAM_GETW(s, zl->nexthop_num); + + if (zl->nexthop_num > MULTIPATH_NUM) { + flog_warn( + EC_LIB_ZAPI_ENCODE, + "%s: Prefix %pFX has %d nexthops, but we can only use the first %d", + __func__, &zl->route.prefix, zl->nexthop_num, + MULTIPATH_NUM); + } + + zl->nexthop_num = MIN(MULTIPATH_NUM, zl->nexthop_num); + for (int i = 0; i < zl->nexthop_num; i++) { znh = &zl->nexthops[i]; -- cgit v1.2.3