From 649654aba22704a792949374990bc2a29c357de8 Mon Sep 17 00:00:00 2001 From: ajs Date: Wed, 16 Nov 2005 20:17:52 +0000 Subject: [ospfd] Standardize buffer sizes used for displaying timers. 2005-11-16 Andrew J. Schorr * ospf_dump.h: Define OSPF_TIME_DUMP_SIZE as appropriate buffer size for use with ospf_timer_dump and ospf_timeval_dump. * ospf_vty.c: Change all buffer sizes used with ospf_timer_dump and ospf_timeval_dump to have size OSPF_TIME_DUMP_SIZE. (show_ip_ospf_interface_sub) Fix possible buffer overflow in call to ospf_timer_dump. --- ospfd/ChangeLog | 9 +++++++++ ospfd/ospf_dump.h | 3 +++ ospfd/ospf_vty.c | 20 +++++++------------- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog index b33ca438..41453bf9 100644 --- a/ospfd/ChangeLog +++ b/ospfd/ChangeLog @@ -1,3 +1,12 @@ +2005-11-16 Andrew J. Schorr + + * ospf_dump.h: Define OSPF_TIME_DUMP_SIZE as appropriate buffer size + for use with ospf_timer_dump and ospf_timeval_dump. + * ospf_vty.c: Change all buffer sizes used with ospf_timer_dump and + ospf_timeval_dump to have size OSPF_TIME_DUMP_SIZE. + (show_ip_ospf_interface_sub) Fix possible buffer overflow in + call to ospf_timer_dump. + 2005-11-16 Andrew J. Schorr * ospf_ism.h: (OSPF_ISM_TIMER_OFF) Improve macro syntax by enclosing diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h index e24244ee..fb813719 100644 --- a/ospfd/ospf_dump.h +++ b/ospfd/ospf_dump.h @@ -137,4 +137,7 @@ extern void ospf_packet_dump (struct stream *); extern void ospf_lsa_header_dump (struct lsa_header *); extern void debug_init (void); +/* Appropriate buffer size to use with ospf_timer_dump and ospf_timeval_dump: */ +#define OSPF_TIME_DUMP_SIZE 16 + #endif /* _ZEBRA_OSPF_DUMP_H */ diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index e28a89c5..de021bc2 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2520,7 +2520,7 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area) /* Stub-router state for this area */ if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) { - char timebuf[9]; + char timebuf[OSPF_TIME_DUMP_SIZE]; vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", VTY_NEWLINE); if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) @@ -2592,7 +2592,7 @@ DEFUN (show_ip_ospf, struct ospf_area * area; struct ospf *ospf; struct timeval result; - char timebuf[13]; /* XX:XX:XX.XXX(nul) */ + char timebuf[OSPF_TIME_DUMP_SIZE]; /* Check OSPF is enable. */ ospf = ospf_lookup (); @@ -2706,7 +2706,6 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, int is_up; struct ospf_neighbor *nbr; struct route_node *rn; - char buf[9]; /* Is interface up? */ vty_out (vty, "%s is %s%s", ifp->name, @@ -2818,14 +2817,9 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) { - int timer_slen = 9; /* length of "hh:mm:ss(nul)" */ - - /* for fast hello we also want to see the .XXXX ms part */ - if (OSPF_IF_PARAM (oi, fast_hello)) - timer_slen += 5; - + char timebuf[OSPF_TIME_DUMP_SIZE]; vty_out (vty, " Hello due in %s%s", - ospf_timer_dump (oi->t_hello, buf, timer_slen), + ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), VTY_NEWLINE); } else /* OSPF_IF_PASSIVE is set */ @@ -2884,7 +2878,7 @@ show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) struct route_node *rn; struct ospf_neighbor *nbr; char msgbuf[16]; - char timebuf[14]; + char timebuf[OSPF_TIME_DUMP_SIZE]; for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) if ((nbr = rn->info)) @@ -3035,7 +3029,7 @@ static void show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma) { - char timebuf[9]; + char timebuf[OSPF_TIME_DUMP_SIZE]; /* Show neighbor ID. */ vty_out (vty, " Neighbor %s,", "-"); @@ -3069,7 +3063,7 @@ static void show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_neighbor *nbr) { - char timebuf[9]; + char timebuf[OSPF_TIME_DUMP_SIZE]; /* Show neighbor ID. */ if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) -- cgit v1.2.1