From: Stephen Worley Date: Fri, 11 Sep 2020 21:59:30 +0000 (-0400) Subject: sharp: add check for num_nh > multipath X-Git-Tag: base_7.6~489^2~5 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=54a701e4c1d61a7bc72161d501c5e4ee5204c929;p=matthieu%2Ffrr.git sharp: add check for num_nh > multipath Add a check for installing nexthop_group greater than multipath number. Truncate if we hit it and log a warning to the user. Signed-off-by: Stephen Worley --- diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 03def0d9ba..edbc7460e0 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -365,6 +365,13 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg) struct nexthop *nh; for (ALL_NEXTHOPS_PTR(nhg, nh)) { + if (nexthop_num >= MULTIPATH_NUM) { + zlog_warn( + "%s: number of nexthops greater than max multipath size, truncating", + __func__); + break; + } + api_nh = &nh_array[nexthop_num]; zapi_nexthop_from_nexthop(api_nh, nh);