]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Trim long neighbor description with no whitespace 13180/head
authorrbarroetavena <rbarroetavena@gmail.com>
Thu, 23 Mar 2023 19:19:48 +0000 (16:19 -0300)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Fri, 31 Mar 2023 20:44:41 +0000 (20:44 +0000)
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>
(cherry picked from commit 420ac3d24cd4f78f05826f7d58a794e0ffc5543f)

bgpd/bgp_vty.c

index 4ec087641142911540f79c5202941ec0cc4ca89f..4b6e6262078493fe01bac72108a2c3871a3fdee9 100644 (file)
@@ -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;
 }