diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 3b22702937..3a66f74f84 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -5145,7 +5145,7 @@ void bgp_path_attribute_discard_vty(struct vty *vty, struct peer *peer, * then flush all. */ if (!discard_attrs) { - for (i = 0; i < BGP_ATTR_MAX; i++) + for (i = 1; i <= BGP_ATTR_MAX; i++) peer->discard_attrs[i] = false; goto discard_soft_clear; } @@ -5154,7 +5154,7 @@ void bgp_path_attribute_discard_vty(struct vty *vty, struct peer *peer, frrstr_split(discard_attrs, " ", &attributes, &num_attributes); if (set) - for (i = 0; i < BGP_ATTR_MAX; i++) + for (i = 1; i <= BGP_ATTR_MAX; i++) peer->discard_attrs[i] = false; for (i = 0; i < num_attributes; i++) { @@ -5214,7 +5214,7 @@ void bgp_path_attribute_withdraw_vty(struct vty *vty, struct peer *peer, * then flush all. */ if (!withdraw_attrs) { - for (i = 0; i < BGP_ATTR_MAX; i++) + for (i = 1; i <= BGP_ATTR_MAX; i++) peer->withdraw_attrs[i] = false; goto withdraw_soft_clear; } @@ -5223,7 +5223,7 @@ void bgp_path_attribute_withdraw_vty(struct vty *vty, struct peer *peer, frrstr_split(withdraw_attrs, " ", &attributes, &num_attributes); if (set) - for (i = 0; i < BGP_ATTR_MAX; i++) + for (i = 1; i <= BGP_ATTR_MAX; i++) peer->withdraw_attrs[i] = false; for (i = 0; i < num_attributes; i++) { diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 60b394b697..f03b6530a0 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4325,7 +4325,7 @@ bool bgp_path_attribute_discard(struct peer *peer, char *buf, size_t size) buf[0] = '\0'; - for (unsigned int i = 0; i < BGP_ATTR_MAX; i++) { + for (unsigned int i = 1; i <= BGP_ATTR_MAX; i++) { if (peer->discard_attrs[i]) snprintf(buf + strlen(buf), size - strlen(buf), "%s%d", (strlen(buf) > 0) ? " " : "", i); @@ -4345,7 +4345,7 @@ bool bgp_path_attribute_treat_as_withdraw(struct peer *peer, char *buf, buf[0] = '\0'; - for (unsigned int i = 0; i < BGP_ATTR_MAX; i++) { + for (unsigned int i = 1; i <= BGP_ATTR_MAX; i++) { if (peer->withdraw_attrs[i]) snprintf(buf + strlen(buf), size - strlen(buf), "%s%d", (strlen(buf) > 0) ? " " : "", i); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index dd8096c574..4a96934a6b 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1802,10 +1802,10 @@ struct peer { #define BGP_ATTR_MAX 255 /* Path attributes discard */ - bool discard_attrs[BGP_ATTR_MAX]; + bool discard_attrs[BGP_ATTR_MAX + 1]; /* Path attributes treat-as-withdraw */ - bool withdraw_attrs[BGP_ATTR_MAX]; + bool withdraw_attrs[BGP_ATTR_MAX + 1]; /* BGP Software Version Capability */ #define BGP_MAX_SOFT_VERSION 64