From e0b1c8ccdf6821e4397edbba9e82dd6010ea2f8f Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 20 May 2023 10:03:10 +0300 Subject: [PATCH] bgpd: Initialize pfx_buf to zeros before using in bgp_path_info_cmp() This can lead into some garbage outputs, that can't be decoded in utf-8 or so. This was catched when testing 76b246aa1f779e17ce6845c6ab0c292497b0008f. Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 4 ++-- bgpd/rfapi/rfapi_import.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4e4dce84fe..2046f74182 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1466,7 +1466,7 @@ int bgp_evpn_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, struct bgp_path_info *exist, int *paths_eq) { enum bgp_path_selection_reason reason; - char pfx_buf[PREFIX2STR_BUFFER]; + char pfx_buf[PREFIX2STR_BUFFER] = {}; return bgp_path_info_cmp(bgp, new, exist, paths_eq, NULL, 0, pfx_buf, AFI_L2VPN, SAFI_EVPN, &reason); @@ -2653,7 +2653,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest, struct bgp_path_info *nextpi = NULL; int paths_eq, do_mpath, debug; struct list mp_list; - char pfx_buf[PREFIX2STR_BUFFER]; + char pfx_buf[PREFIX2STR_BUFFER] = {}; char path_buf[PATH_ADDPATH_STR_BUFFER]; bgp_mp_list_init(&mp_list); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 4b8e07a9c4..27f7c88d7b 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -1939,7 +1939,7 @@ static void rfapiBgpInfoAttachSorted(struct agg_node *rn, struct bgp *bgp; struct bgp_path_info *prev; struct bgp_path_info *next; - char pfx_buf[PREFIX2STR_BUFFER]; + char pfx_buf[PREFIX2STR_BUFFER] = {}; bgp = bgp_get_default(); /* assume 1 instance for now */ -- 2.39.5