summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_debug.c2
-rw-r--r--bgpd/bgpd.c7
-rw-r--r--bgpd/bgpd.h3
3 files changed, 7 insertions, 5 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index fde1bdd7ce..64f71bebc9 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -509,7 +509,7 @@ const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data,
return NULL;
uint8_t len = data[0];
- if (len > 128 || len > datalen - 1)
+ if (!len || len > datalen - 1)
return NULL;
return zlog_sanitize(buf, bufsz, data + 1, len);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 789c156da4..3921ad2367 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -4272,17 +4272,16 @@ static void peer_flag_modify_action(struct peer *peer, uint32_t flag)
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
char *msg = peer->tx_shutdown_message;
size_t msglen;
+ uint8_t msgbuf[BGP_ADMIN_SHUTDOWN_MSG_LEN + 1];
if (!msg && peer_group_active(peer))
msg = peer->group->conf
->tx_shutdown_message;
msglen = msg ? strlen(msg) : 0;
- if (msglen > 128)
- msglen = 128;
+ if (msglen > BGP_ADMIN_SHUTDOWN_MSG_LEN)
+ msglen = BGP_ADMIN_SHUTDOWN_MSG_LEN;
if (msglen) {
- uint8_t msgbuf[129];
-
msgbuf[0] = msglen;
memcpy(msgbuf + 1, msg, msglen);
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index f4d7ab769a..865a50757f 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1731,6 +1731,9 @@ struct bgp_nlri {
/* Default BGP port number. */
#define BGP_PORT_DEFAULT 179
+/* Extended BGP Administrative Shutdown Communication */
+#define BGP_ADMIN_SHUTDOWN_MSG_LEN 255
+
/* BGP minimum message size. */
#define BGP_MSG_OPEN_MIN_SIZE (BGP_HEADER_SIZE + 10)
#define BGP_MSG_UPDATE_MIN_SIZE (BGP_HEADER_SIZE + 4)