]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Trim long neighbor description with no whitespace 13139/head
authorrbarroetavena <rbarroetavena@gmail.com>
Thu, 23 Mar 2023 19:19:48 +0000 (16:19 -0300)
committerrbarroetavena <rbarroetavena@gmail.com>
Thu, 30 Mar 2023 16:15:58 +0000 (13:15 -0300)
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 <rbarroetavena@gmail.com>
bgpd/bgp_vty.c

index 4bbbced806822bb52f19c211683ab5d1c3e0ea24..a436490ba1deddcf596a2484e337394fbd282fcd 100644 (file)
@@ -11036,10 +11036,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;
                }
@@ -11049,10 +11049,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;
 }