From: paco Date: Tue, 19 Jun 2018 17:12:36 +0000 (+0200) Subject: bgpd: json output fix (Coverity 1470098) X-Git-Tag: frr-6.1-dev~278^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=06e896446473041c003e97acc79231dc166ccf13;p=mirror%2Ffrr.git bgpd: json output fix (Coverity 1470098) Signed-off-by: F. Aragon --- diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c index 351f91dd1a..cc05194703 100644 --- a/bgpd/bgp_vpn.c +++ b/bgpd/bgp_vpn.c @@ -223,21 +223,27 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer, } rd_header = 0; } - route_vty_out_tmp(vty, &rm->p, attr, - SAFI_MPLS_VPN, - use_json, json_array); + if (use_json) { + char buf_a[BUFSIZ]; + char buf_b[BUFSIZ]; + + sprintf(buf_a, "%s/%d", + inet_ntop(rm->p.family, + rm->p.u.val, + buf_b, + BUFSIZ), + rm->p.prefixlen); + json_object_object_add( + json_routes, buf_a, + json_array); + } else { + route_vty_out_tmp( + vty, &rm->p, attr, + SAFI_MPLS_VPN, use_json, + json_array); + } } } - if (use_json && rm) { - char buf_a[BUFSIZ]; - char buf_b[BUFSIZ]; - sprintf(buf_a, "%s/%d", - inet_ntop(rm->p.family, rm->p.u.val, - buf_b, BUFSIZ), - rm->p.prefixlen); - json_object_object_add(json_routes, buf_a, - json_array); - } } } if (use_json) {