summaryrefslogtreecommitdiff
path: root/ctdb/server
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2022-01-21 12:09:45 +1100
committerAmitay Isaacs <amitay@samba.org>2022-05-03 09:19:31 +0000
commit490e5f4d4ce2facd4c396a2e213f53de923629c2 (patch)
tree5605c24e3c418de504021c24a680e9808e6cc2c9 /ctdb/server
parent45b648486b9751beba7500c25294b4f7671caf44 (diff)
downloadsamba-490e5f4d4ce2facd4c396a2e213f53de923629c2.tar.gz
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>
Diffstat (limited to 'ctdb/server')
-rw-r--r--ctdb/server/ctdb_mutex_fcntl_helper.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/ctdb/server/ctdb_mutex_fcntl_helper.c b/ctdb/server/ctdb_mutex_fcntl_helper.c
index 87f5dc22c41..97a4a1d4a71 100644
--- a/ctdb/server/ctdb_mutex_fcntl_helper.c
+++ b/ctdb/server/ctdb_mutex_fcntl_helper.c
@@ -150,9 +150,9 @@ static void wait_for_parent_check(struct tevent_req *subreq)
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;
}
@@ -265,9 +265,9 @@ static void wait_for_lost_check(struct tevent_req *subreq)
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;
}
@@ -325,14 +325,16 @@ static void wait_for_exit_parent_done(struct tevent_req *subreq)
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
bool status;
+ int err;
- status = wait_for_parent_recv(subreq);
+ status = wait_for_parent_recv(subreq, &err);
TALLOC_FREE(subreq);
if (! status) {
/* Ignore error */
fprintf(stderr,
"ctdb_mutex_fcntl_helper: "
- "wait_for_parent_recv() failed\n");
+ "wait_for_parent_recv() failed (%d)\n",
+ err);
}
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(
subreq, struct tevent_req);
bool status;
+ int err;
- status = wait_for_lost_recv(subreq);
+ status = wait_for_lost_recv(subreq, &err);
TALLOC_FREE(subreq);
if (! status) {
/* Ignore error */
fprintf(stderr,
"ctdb_mutex_fcntl_helper: "
- "wait_for_lost_recv() failed\n");
+ "wait_for_lost_recv() failed (%d)\n",
+ err);
}
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;
}
@@ -429,11 +433,12 @@ int main(int argc, char *argv[])
tevent_req_poll(req, ev);
- status = wait_for_exit_recv(req);
+ status = wait_for_exit_recv(req, &ret);
if (! status) {
fprintf(stderr,
- "%s: wait_for_exit_recv() failed\n",
- progname);
+ "%s: wait_for_exit_recv() failed (%d)\n",
+ progname,
+ ret);
}
if (fd != -1) {