From 517cd68a3e308c69c15db6d707f62854e5379033 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 7 Feb 2017 14:55:39 -0500 Subject: [PATCH] bgpd: Fix usage of uninitialized dn_flag[] dn_flag was tested inside of a 'use_json' block further down in the function. Move initialization of the value to outside of the !use_json if statement Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 51839b784b..c17bb66846 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7337,6 +7337,10 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) json_neigh = json_object_new_object(); + memset (dn_flag, '\0', sizeof (dn_flag)); + if (!p->conf_if && peer_dynamic_neighbor (p)) + dn_flag[0] = '*'; + if (!use_json) { if (p->conf_if) /* Configured interface name. */ @@ -7344,13 +7348,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js BGP_PEER_SU_UNSPEC(p) ? "None" : sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); else /* Configured IP address. */ - { - memset(dn_flag, '\0', sizeof(dn_flag)); - if (peer_dynamic_neighbor(p)) - dn_flag[0] = '*'; - vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); - } } if (use_json) -- 2.39.5