diff options
author | Volker Lendecke <vl@samba.org> | 2009-08-29 09:41:32 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2009-09-09 12:45:08 +0200 |
commit | 5805ecffe1f5fe5cb92836d159c761849c018eed (patch) | |
tree | 3fdad2242ace4d34d6d89f1831542a8a3d060ec9 | |
parent | 581a85eeb1cbed45d2eddee20fab1a168fdb1518 (diff) | |
download | samba-5805ecffe1f5fe5cb92836d159c761849c018eed.tar.gz |
tevent: Fix a segfault upon the first signal
When the first signal arrives, tevent_common_signal_handler() crashed: "ev" is
initialized to NULL, so the first "write(ev->pipe_fds[1], &c, 1);" dereferences
NULL.
Rusty, Tridge, please check. Also, can you tell me a bit more about the
environment you tested this in? I'd be curious to see where this survived.
Thanks,
Volker
(cherry picked from commit 23abcd2318c69753aa2a144e1dc0f9cf9efdb705)
(cherry picked from commit 1108225c1316521bf2bb59c9b99b030440af0002)
-rw-r--r-- | lib/tevent/tevent_signal.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c index 0333325ef0f..b329f8c1e72 100644 --- a/lib/tevent/tevent_signal.c +++ b/lib/tevent/tevent_signal.c @@ -85,6 +85,12 @@ static void tevent_common_signal_handler(int signum) SIG_INCREMENT(sig_state->signal_count[signum]); SIG_INCREMENT(sig_state->got_signal); + if (sig_state->sig_handlers[signum] != NULL) { + ev = sig_state->sig_handlers[signum]->se->event_ctx; + /* doesn't matter if this pipe overflows */ + res = write(ev->pipe_fds[1], &c, 1); + } + /* Write to each unique event context. */ for (sl = sig_state->sig_handlers[signum]; sl; sl = sl->next) { if (sl->se->event_ctx != ev) { |