From 50aef6f3b0e36b56cfa9f3d374be0c1d25c30c45 Mon Sep 17 00:00:00 2001 From: Chris Caputo Date: Tue, 23 Jun 2009 06:06:49 +0000 Subject: Fix "show ip bgp dampened-paths" garbage output. * bgpd/bgp_damp.c: Make bgp_damp_reuse_time_vty() accept a buffer and length, rather than returning a local var buffer whose contents can get trounced. Remove duplicate BGP_UPTIME_LEN define. * bgpd/bgp_damp.h: bgp_damp_reuse_time_vty() prototype change. * bgpd/bgp_route.c: Provide bgp_damp_reuse_time_vty() with a buffer and length. Remove duplicate BGP_UPTIME_LEN define. This problem was noticed in 2005... http://hibernia.jakma.org/~paul/patches/quagga-test.diff ...but the fix didn't make it into the code. Signed-off-by: Chris Caputo --- bgpd/bgp_damp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'bgpd/bgp_damp.c') diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 346ba520..e21131ef 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -541,8 +541,6 @@ bgp_config_write_damp (struct vty *vty) VTY_NEWLINE); } -#define BGP_UPTIME_LEN 25 - static const char * bgp_get_reuse_time (unsigned int penalty, char *buf, size_t len) { @@ -616,11 +614,11 @@ bgp_damp_info_vty (struct vty *vty, struct bgp_info *binfo) } const char * -bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_info *binfo) +bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_info *binfo, + char *timebuf, size_t len) { struct bgp_damp_info *bdi; time_t t_now, t_diff; - char timebuf[BGP_UPTIME_LEN]; int penalty; if (!binfo->extra) @@ -639,5 +637,5 @@ bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_info *binfo) t_diff = t_now - bdi->t_updated; penalty = bgp_damp_decay (t_diff, bdi->penalty); - return bgp_get_reuse_time (penalty, timebuf, BGP_UPTIME_LEN); + return bgp_get_reuse_time (penalty, timebuf, len); } -- cgit v1.2.1