]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Set the software version capability received flag only after a validation
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 8 Nov 2023 13:26:40 +0000 (15:26 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 9 Nov 2023 14:03:01 +0000 (16:03 +0200)
We shouldn't set it blindly once the packet is received, but first we have to
do some sanity checks.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_open.c

index 6ee5b5dc5cda7aed11ef6b67d369ad5ae7291eda..b030c455bcb26c32f47486ae130537e9a0dcccc8 100644 (file)
@@ -889,8 +889,6 @@ static int bgp_capability_software_version(struct peer *peer,
        size_t end = stream_get_getp(s) + hdr->length;
        uint8_t len;
 
-       SET_FLAG(peer->cap, PEER_CAP_SOFT_VERSION_RCV);
-
        len = stream_getc(s);
        if (stream_get_getp(s) + len > end) {
                flog_warn(
@@ -900,6 +898,8 @@ static int bgp_capability_software_version(struct peer *peer,
                return -1;
        }
 
+       SET_FLAG(peer->cap, PEER_CAP_SOFT_VERSION_RCV);
+
        if (len > BGP_MAX_SOFT_VERSION) {
                flog_warn(EC_BGP_CAPABILITY_INVALID_LENGTH,
                          "%s: Received Software Version, but the length is too big, truncating, from peer %s",