From: rbarroetavena Date: Thu, 23 Mar 2023 19:19:48 +0000 (-0300) Subject: bgpd: Trim long neighbor description with no whitespace X-Git-Tag: docker/8.5.1~22^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b8b43bc5b425bc15dc1f779d82bbf8d07266cb02;p=matthieu%2Ffrr.git bgpd: Trim long neighbor description with no whitespace Fix for missing neighbor description in "show bgp summary [wide]" when its length exceeds 20[64] chars and it doesn't contain withespaces. Existing behavior remains if description contains whitespaces before size limit. Signed-off-by: rbarroetavena (cherry picked from commit 420ac3d24cd4f78f05826f7d58a794e0ffc5543f) --- diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4ec0876411..4b6e626207 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10849,10 +10849,10 @@ static char *bgp_peer_description_stripped(char *desc, uint32_t size) { static char stripped[BUFSIZ]; uint32_t i = 0; - uint32_t last_space = 0; + uint32_t last_space = size; while (i < size) { - if (*(desc + i) == 0) { + if (*(desc + i) == '\0') { stripped[i] = '\0'; return stripped; } @@ -10862,10 +10862,7 @@ static char *bgp_peer_description_stripped(char *desc, uint32_t size) i++; } - if (last_space > size) - stripped[size + 1] = '\0'; - else - stripped[last_space] = '\0'; + stripped[last_space] = '\0'; return stripped; }