]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix memory leak for bgp_notify_receive()
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 4 May 2022 10:27:47 +0000 (13:27 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 4 May 2022 10:40:15 +0000 (13:40 +0300)
Initialize outer/inner bgp_notify structs to zero.

Free bgp_notify.raw_data after use.

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

index 54db4da0c298ee844ebd77c7a87ce428078a8ec2..88eeab6ed1642aa846d4167a3f69de5a0b503c43 100644 (file)
@@ -1973,8 +1973,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
  */
 static int bgp_notify_receive(struct peer *peer, bgp_size_t size)
 {
-       struct bgp_notify outer;
-       struct bgp_notify inner;
+       struct bgp_notify outer = {};
+       struct bgp_notify inner = {};
        bool hard_reset = false;
 
        if (peer->notify.data) {
@@ -2039,12 +2039,13 @@ static int bgp_notify_receive(struct peer *peer, bgp_size_t size)
                }
 
                bgp_notify_print(peer, &inner, "received", hard_reset);
-               if (inner.data) {
+               if (inner.length) {
                        XFREE(MTYPE_BGP_NOTIFICATION, inner.data);
                        inner.length = 0;
                }
                if (outer.length) {
                        XFREE(MTYPE_BGP_NOTIFICATION, outer.data);
+                       XFREE(MTYPE_BGP_NOTIFICATION, outer.raw_data);
                        outer.length = 0;
                }
        }