]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-mutex: Don't pass NULL to tevent_req_is_unix_error()
authorMartin Schwenke <martin@meltin.net>
Fri, 21 Jan 2022 01:09:45 +0000 (12:09 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 3 May 2022 09:19:31 +0000 (09:19 +0000)
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>
ctdb/server/ctdb_mutex_fcntl_helper.c

index 87f5dc22c41de24f8907c29a8b056f31036e812a..97a4a1d4a71f53deca3dfc60ac8f42bbffdb7d67 100644 (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);
 }
 
-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) {