diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2017-04-19 20:15:56 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2017-04-26 15:36:33 +0200 |
commit | 835a7376b732ae21ea5d033211de050d1613f444 (patch) | |
tree | 46820e6cff05bc1cbbf651b086bef2d53d045f77 /ldpd/ldpe.c | |
parent | ldpd: simplify initialization of the child processes (diff) | |
download | frr-835a7376b732ae21ea5d033211de050d1613f444.tar.xz frr-835a7376b732ae21ea5d033211de050d1613f444.zip |
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>
Diffstat (limited to 'ldpd/ldpe.c')
-rw-r--r-- | ldpd/ldpe.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 1248d4f86..bd0f9dbd6 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -196,9 +196,11 @@ ldpe_shutdown(void) struct adj *adj; /* close pipes */ - msgbuf_write(&iev_lde->ibuf.w); - msgbuf_clear(&iev_lde->ibuf.w); - close(iev_lde->ibuf.fd); + if (iev_lde) { + msgbuf_write(&iev_lde->ibuf.w); + msgbuf_clear(&iev_lde->ibuf.w); + close(iev_lde->ibuf.fd); + } msgbuf_write(&iev_main->ibuf.w); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -226,7 +228,8 @@ ldpe_shutdown(void) adj_del(adj, S_SHUTDOWN); /* clean up */ - free(iev_lde); + if (iev_lde) + free(iev_lde); free(iev_main); free(iev_main_sync); free(pkt_ptr); |