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 <chris@opensourcerouting.org>
This commit is contained in:
Christian Franke 2017-02-23 14:27:00 +01:00
parent b2184d8adc
commit b79d6f95a3
2 changed files with 4 additions and 0 deletions

View File

@ -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';
}

View File

@ -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. */