diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2024-09-26 15:56:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-26 15:56:19 -0400 |
| commit | cf5b42e3fe06f43892bcbe786d88a33c618ad29e (patch) | |
| tree | acc66453286e2c8e1b66bbf42c0f94c8d760ddab | |
| parent | 52c9723dafcd85c1a158f645d87c8b75601b2138 (diff) | |
| parent | c68a7fb9456015eb77889fcdff6235851dab2ce6 (diff) | |
Merge pull request #16936 from FRRouting/mergify/bp/stable/10.1/pr-16579
bgpd: Avoid use-after-free when doing `no router bgp` with auto created instances (backport #16579)
| -rw-r--r-- | bgpd/bgp_vty.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1a87799ad2..fd96057a78 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1695,15 +1695,18 @@ DEFUN (no_router_bgp, /* Cannot delete default instance if vrf instances exist */ if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { - struct listnode *node; + struct listnode *node, *nnode; struct bgp *tmp_bgp; - for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { + for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, tmp_bgp)) { if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) continue; - if (CHECK_FLAG(tmp_bgp->vrf_flags, BGP_VRF_AUTO)) + if (CHECK_FLAG(tmp_bgp->vrf_flags, + BGP_VRF_AUTO)) { bgp_delete(tmp_bgp); + continue; + } if (CHECK_FLAG( tmp_bgp->af_flags[AFI_IP] |
