From f9c86734e52e9850ea5e7474f29d8c88c2e90836 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 25 Feb 2024 08:04:15 -0500 Subject: [PATCH] bgpd: Allow string creation to handle NULL case Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 54ab15a9f1..c91745030d 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -572,6 +572,11 @@ void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi, char *buf, { struct peer *peer; + if (!pi) { + snprintf(buf, buf_len, "NONE"); + return; + } + if (pi->sub_type == BGP_ROUTE_IMPORTED && bgp_get_imported_bpi_ultimate(pi)) peer = bgp_get_imported_bpi_ultimate(pi)->peer; @@ -2893,11 +2898,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest, * qualify as multipaths */ if (debug) { - if (new_select) - bgp_path_info_path_with_addpath_rx_str( - new_select, path_buf, sizeof(path_buf)); - else - snprintf(path_buf, sizeof(path_buf), "NONE"); + bgp_path_info_path_with_addpath_rx_str(new_select, path_buf, + sizeof(path_buf)); zlog_debug( "%pBD(%s): After path selection, newbest is %s oldbest was %s", dest, bgp->name_pretty, path_buf, -- 2.39.5