From: Christian Franke Date: Thu, 23 Feb 2017 13:27:00 +0000 (+0100) Subject: bgpd: fix bgp_info_addpath_{rx,tx}_str if addpath info is not present X-Git-Tag: frr-3.0-branchpoint~23^2~1^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b79d6f95a3e716708b8010ddd03a3fa4272792a6;p=mirror%2Ffrr.git bgpd: fix bgp_info_addpath_{rx,tx}_str if addpath info is not present The buffer needs to be set to length 0 if nothing is written into it, otherwise bgpd will log uninitialized memory, disclosing information and possibly leading to a crash. Signed-off-by: Christian Franke --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 3e5251a7ff..353ecd6934 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2281,6 +2281,8 @@ bgp_info_addpath_rx_str(u_int32_t addpath_id, char *buf) { if (addpath_id) sprintf(buf, " with addpath ID %d", addpath_id); + else + buf[0] = '\0'; } diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index ce2e0dbca0..0dcc8fb222 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -619,6 +619,8 @@ bgp_info_addpath_tx_str (int addpath_encode, u_int32_t addpath_tx_id, { if (addpath_encode) sprintf(buf, " with addpath ID %d", addpath_tx_id); + else + buf[0] = '\0'; } /* Make BGP update packet. */