1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

ctdb-mutex: Don't pass NULL to tevent_req_is_unix_error()

If there is an error then this pointer is unconditionally
dereferenced.

However, the only possible error appears to be ENOMEM, where a crash
caused by dereferencing a NULL pointer isn't a terrible outcome.  In
the absence of a security issue this is probably not worth
backporting.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2022-01-21 12:09:45 +11:00 committed by Amitay Isaacs
parent 45b648486b
commit 490e5f4d4c

View File

@ -150,9 +150,9 @@ static void wait_for_parent_check(struct tevent_req *subreq)
tevent_req_set_callback(subreq, wait_for_parent_check, req); tevent_req_set_callback(subreq, wait_for_parent_check, req);
} }
static bool wait_for_parent_recv(struct tevent_req *req) static bool wait_for_parent_recv(struct tevent_req *req, int *perr)
{ {
if (tevent_req_is_unix_error(req, NULL)) { if (tevent_req_is_unix_error(req, perr)) {
return false; return false;
} }
@ -265,9 +265,9 @@ static void wait_for_lost_check(struct tevent_req *subreq)
tevent_req_set_callback(subreq, wait_for_lost_check, req); tevent_req_set_callback(subreq, wait_for_lost_check, req);
} }
static bool wait_for_lost_recv(struct tevent_req *req) static bool wait_for_lost_recv(struct tevent_req *req, int *perr)
{ {
if (tevent_req_is_unix_error(req, NULL)) { if (tevent_req_is_unix_error(req, perr)) {
return false; return false;
} }
@ -325,14 +325,16 @@ static void wait_for_exit_parent_done(struct tevent_req *subreq)
struct tevent_req *req = tevent_req_callback_data( struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req); subreq, struct tevent_req);
bool status; bool status;
int err;
status = wait_for_parent_recv(subreq); status = wait_for_parent_recv(subreq, &err);
TALLOC_FREE(subreq); TALLOC_FREE(subreq);
if (! status) { if (! status) {
/* Ignore error */ /* Ignore error */
fprintf(stderr, fprintf(stderr,
"ctdb_mutex_fcntl_helper: " "ctdb_mutex_fcntl_helper: "
"wait_for_parent_recv() failed\n"); "wait_for_parent_recv() failed (%d)\n",
err);
} }
tevent_req_done(req); tevent_req_done(req);
@ -343,22 +345,24 @@ static void wait_for_exit_lost_done(struct tevent_req *subreq)
struct tevent_req *req = tevent_req_callback_data( struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req); subreq, struct tevent_req);
bool status; bool status;
int err;
status = wait_for_lost_recv(subreq); status = wait_for_lost_recv(subreq, &err);
TALLOC_FREE(subreq); TALLOC_FREE(subreq);
if (! status) { if (! status) {
/* Ignore error */ /* Ignore error */
fprintf(stderr, fprintf(stderr,
"ctdb_mutex_fcntl_helper: " "ctdb_mutex_fcntl_helper: "
"wait_for_lost_recv() failed\n"); "wait_for_lost_recv() failed (%d)\n",
err);
} }
tevent_req_done(req); tevent_req_done(req);
} }
static bool wait_for_exit_recv(struct tevent_req *req) static bool wait_for_exit_recv(struct tevent_req *req, int *perr)
{ {
if (tevent_req_is_unix_error(req, NULL)) { if (tevent_req_is_unix_error(req, perr)) {
return false; return false;
} }
@ -429,11 +433,12 @@ int main(int argc, char *argv[])
tevent_req_poll(req, ev); tevent_req_poll(req, ev);
status = wait_for_exit_recv(req); status = wait_for_exit_recv(req, &ret);
if (! status) { if (! status) {
fprintf(stderr, fprintf(stderr,
"%s: wait_for_exit_recv() failed\n", "%s: wait_for_exit_recv() failed (%d)\n",
progname); progname,
ret);
} }
if (fd != -1) { if (fd != -1) {