mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 22:07:43 +00:00
ldpd: fix segfault after failed initialization
When ldpd fails to start for some reason, like failing to create a pid file, the child processes call their shutdown functions without being completely initialized. This patch adds some protections to prevent a segmentation fault on such circumstances. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
e75f810c2f
commit
b3121cd7d1
@ -216,8 +216,10 @@ static void
|
|||||||
lde_shutdown(void)
|
lde_shutdown(void)
|
||||||
{
|
{
|
||||||
/* close pipes */
|
/* close pipes */
|
||||||
msgbuf_clear(&iev_ldpe->ibuf.w);
|
if (iev_ldpe) {
|
||||||
close(iev_ldpe->ibuf.fd);
|
msgbuf_clear(&iev_ldpe->ibuf.w);
|
||||||
|
close(iev_ldpe->ibuf.fd);
|
||||||
|
}
|
||||||
msgbuf_clear(&iev_main->ibuf.w);
|
msgbuf_clear(&iev_main->ibuf.w);
|
||||||
close(iev_main->ibuf.fd);
|
close(iev_main->ibuf.fd);
|
||||||
msgbuf_clear(&iev_main_sync->ibuf.w);
|
msgbuf_clear(&iev_main_sync->ibuf.w);
|
||||||
@ -229,7 +231,8 @@ lde_shutdown(void)
|
|||||||
|
|
||||||
config_clear(ldeconf);
|
config_clear(ldeconf);
|
||||||
|
|
||||||
free(iev_ldpe);
|
if (iev_ldpe)
|
||||||
|
free(iev_ldpe);
|
||||||
free(iev_main);
|
free(iev_main);
|
||||||
free(iev_main_sync);
|
free(iev_main_sync);
|
||||||
|
|
||||||
|
11
ldpd/ldpe.c
11
ldpd/ldpe.c
@ -196,9 +196,11 @@ ldpe_shutdown(void)
|
|||||||
struct adj *adj;
|
struct adj *adj;
|
||||||
|
|
||||||
/* close pipes */
|
/* close pipes */
|
||||||
msgbuf_write(&iev_lde->ibuf.w);
|
if (iev_lde) {
|
||||||
msgbuf_clear(&iev_lde->ibuf.w);
|
msgbuf_write(&iev_lde->ibuf.w);
|
||||||
close(iev_lde->ibuf.fd);
|
msgbuf_clear(&iev_lde->ibuf.w);
|
||||||
|
close(iev_lde->ibuf.fd);
|
||||||
|
}
|
||||||
msgbuf_write(&iev_main->ibuf.w);
|
msgbuf_write(&iev_main->ibuf.w);
|
||||||
msgbuf_clear(&iev_main->ibuf.w);
|
msgbuf_clear(&iev_main->ibuf.w);
|
||||||
close(iev_main->ibuf.fd);
|
close(iev_main->ibuf.fd);
|
||||||
@ -226,7 +228,8 @@ ldpe_shutdown(void)
|
|||||||
adj_del(adj, S_SHUTDOWN);
|
adj_del(adj, S_SHUTDOWN);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
free(iev_lde);
|
if (iev_lde)
|
||||||
|
free(iev_lde);
|
||||||
free(iev_main);
|
free(iev_main);
|
||||||
free(iev_main_sync);
|
free(iev_main_sync);
|
||||||
free(pkt_ptr);
|
free(pkt_ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user