Avoid overrunning the fixed-size array of nexthops in a
zapi_nhg.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
if (!CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ACTIVE))
continue;
+ /* Don't overrun the zapi buffer. */
+ if (api_nhg.nexthop_num == MULTIPATH_NUM)
+ break;
+
/* overwrite the gw */
if (v4_nhg)
nh.gate.ipv4 = es_vtep->vtep_ip;
if (!api_nhg.nexthop_num)
return;
- if (api_nhg.nexthop_num > MULTIPATH_NUM)
- return;
-
zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
}