]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: json output fix (Coverity 1470098) 2498/head
authorpaco <paco@voltanet.io>
Tue, 19 Jun 2018 17:12:36 +0000 (19:12 +0200)
committerpaco <paco@voltanet.io>
Wed, 20 Jun 2018 13:43:19 +0000 (15:43 +0200)
Signed-off-by: F. Aragon <paco@voltanet.io>
bgpd/bgp_vpn.c

index 351f91dd1a046ef45810a7d75e8d854b97a46305..cc051947031949ba75b2106da7d4678ddf4b2390 100644 (file)
@@ -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) {