]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: fix cleanup of dampening configuration
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 19 Oct 2018 18:53:46 +0000 (15:53 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 17 Dec 2018 14:14:04 +0000 (12:14 -0200)
The bgp_damp_config_clean() function was deallocating some arrays without
resetting the variables that represent their sizes. This was leading to
some crashes because other parts of the code iterate over these arrays
by looking at their corresponding sizes, which could be invalid.

Fixes the following segfaults (which only happen under certain
circumstances):
vtysh -c "configure terminal" -c "router bgp 1" -c "bgp dampening"
vtysh -c "configure terminal" -c "router bgp 1" -c "no bgp dampening"
vtysh -c "configure terminal" -c "router bgp 1" -c "no bgp dampening 45"
vtysh -c "" -c "clear ip bgp dampening"

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
bgpd/bgp_damp.c

index bce6056ded4adaae98f71431e86ebcffd618ccfb..4a0395cabe5b9e3aaae4e6bec1aade6347214254 100644 (file)
@@ -446,12 +446,15 @@ static void bgp_damp_config_clean(struct bgp_damp_config *damp)
 {
        /* Free decay array */
        XFREE(MTYPE_BGP_DAMP_ARRAY, damp->decay_array);
+       damp->decay_array_size = 0;
 
        /* Free reuse index array */
        XFREE(MTYPE_BGP_DAMP_ARRAY, damp->reuse_index);
+       damp->reuse_index_size = 0;
 
        /* Free reuse list array. */
        XFREE(MTYPE_BGP_DAMP_ARRAY, damp->reuse_list);
+       damp->reuse_list_size = 0;
 }
 
 /* Clean all the bgp_damp_info stored in reuse_list. */