bgpd: crash from not NULLing freed pointers
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
There was a crash from not NULLing out peer->hostname but I cleaned
up a bunch of other suspect ones as well.
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index e1ae494..4ab5b06 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -967,8 +967,13 @@
}
}
bgp_notify_print (peer, &bgp_notify, "sending");
+
if (bgp_notify.data)
- XFREE (MTYPE_TMP, bgp_notify.data);
+ {
+ XFREE (MTYPE_TMP, bgp_notify.data);
+ bgp_notify.data = NULL;
+ bgp_notify.length = 0;
+ }
}
if (BGP_DEBUG (normal, NORMAL))
@@ -1973,7 +1978,11 @@
bgp_notify_print(peer, &bgp_notify, "received");
if (bgp_notify.data)
- XFREE (MTYPE_TMP, bgp_notify.data);
+ {
+ XFREE (MTYPE_TMP, bgp_notify.data);
+ bgp_notify.data = NULL;
+ bgp_notify.length = 0;
+ }
}
/* peer count update */