]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Clear previously allocated capabilities values before parsing a new OPEN
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 6 Aug 2024 15:19:40 +0000 (18:19 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 7 Aug 2024 07:16:26 +0000 (10:16 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_packet.c

index 842fd1734ad390f17f61f568829ed19c91b27939..2a2c9bdba9967d19a701e21afe0e885cbcc69239 100644 (file)
@@ -1804,6 +1804,23 @@ static int bgp_open_receive(struct peer_connection *connection,
        mp_capability = 0;
        optlen = stream_getc(peer->curr);
 
+       /* If we previously had some more capabilities e.g.:
+        *   FQDN, SOFT_VERSION, we MUST clear the values we used
+        *   before, to avoid using stale data.
+        * Checking peer->cap is enough before checking for the real
+        * data, but we don't have this check everywhere in the code,
+        * thus let's clear the data here too before parsing the
+        * capabilities.
+        */
+       if (peer->hostname)
+               XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
+
+       if (peer->domainname)
+               XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
+
+       if (peer->soft_version)
+               XFREE(MTYPE_BGP_SOFT_VERSION, peer->soft_version);
+
        /* Extended Optional Parameters Length for BGP OPEN Message */
        if (optlen == BGP_OPEN_NON_EXT_OPT_LEN
            || CHECK_FLAG(peer->flags, PEER_FLAG_EXTENDED_OPT_PARAMS)) {