]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Set ADD-PATH capability received flag only if parsed correctly
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 16 Jan 2024 12:36:20 +0000 (14:36 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 16 Jan 2024 12:36:20 +0000 (14:36 +0200)
If we receive a malformed packet, we might end-up with a bad state.

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

index b85e717457861bac73c0c7b9a44cc3a101aa42f6..8b4f97d6259a7040e992d65f4b9678105ada5702 100644 (file)
@@ -662,8 +662,6 @@ static int bgp_capability_addpath(struct peer *peer,
        struct stream *s = BGP_INPUT(peer);
        size_t end = stream_get_getp(s) + hdr->length;
 
-       SET_FLAG(peer->cap, PEER_CAP_ADDPATH_RCV);
-
        /* Verify length is a multiple of 4 */
        if (hdr->length % CAPABILITY_CODE_ADDPATH_LEN) {
                flog_warn(
@@ -673,6 +671,8 @@ static int bgp_capability_addpath(struct peer *peer,
                return -1;
        }
 
+       SET_FLAG(peer->cap, PEER_CAP_ADDPATH_RCV);
+
        while (stream_get_getp(s) + CAPABILITY_CODE_ADDPATH_LEN <= end) {
                afi_t afi;
                safi_t safi;