From: Donatas Abraitis Date: Wed, 4 May 2022 10:27:47 +0000 (+0300) Subject: bgpd: Fix memory leak for bgp_notify_receive() X-Git-Tag: base_8.3~98^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=10d476d4b98cff3f5394ad370505afdccff60f9a;p=matthieu%2Ffrr.git bgpd: Fix memory leak for bgp_notify_receive() Initialize outer/inner bgp_notify structs to zero. Free bgp_notify.raw_data after use. Signed-off-by: Donatas Abraitis --- diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 54db4da0c2..88eeab6ed1 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -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; } }