From 35a45e80703a5a96b09257c9bb44ec79df6c6337 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 23 Jul 2021 15:14:54 +0300 Subject: [PATCH] bgpd: Use strcmp comparing BGP alias with an actual entered alias It might be a case when a partial match is hit and this needs to be fixed. Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 6 ++---- bgpd/bgp_routemap.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index d5bb53ad8d..66ff16d53a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10862,8 +10862,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, const char *com2alias = bgp_community2alias( communities[i]); - if (strncmp(alias, com2alias, - strlen(com2alias)) + if (strcmp(alias, com2alias) == 0) { found = true; break; @@ -10878,8 +10877,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, const char *com2alias = bgp_community2alias( communities[i]); - if (strncmp(alias, com2alias, - strlen(com2alias)) + if (strcmp(alias, com2alias) == 0) { found = true; break; diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 5b1044754e..61f57d0475 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1195,7 +1195,7 @@ route_match_alias(void *rule, const struct prefix *prefix, void *object) for (int i = 0; i < num; i++) { const char *com2alias = bgp_community2alias(communities[i]); - if (strncmp(alias, com2alias, strlen(com2alias)) == 0) + if (strcmp(alias, com2alias) == 0) return RMAP_MATCH; } } @@ -1206,7 +1206,7 @@ route_match_alias(void *rule, const struct prefix *prefix, void *object) for (int i = 0; i < num; i++) { const char *com2alias = bgp_community2alias(communities[i]); - if (strncmp(alias, com2alias, strlen(com2alias)) == 0) + if (strcmp(alias, com2alias) == 0) return RMAP_MATCH; } } -- 2.39.5