ctdb-locking: Don't pass NULL to tevent_req_is_unix_error()
authorMartin Schwenke <martin@meltin.net>
Fri, 21 Jan 2022 01:14:05 +0000 (12:14 +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_lock_helper.c

index 6b6fbbe27a52297088096989154e6136f03b1902..51d2992b64ebf27c33ec88f8a2cf93f555294fdd 100644 (file)
@@ -230,9 +230,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;
        }
 
@@ -273,6 +273,7 @@ int main(int argc, char *argv[])
        int ppid;
        const char *lock_type;
        bool status;
+       int err;
 
        reset_scheduler();
 
@@ -336,9 +337,11 @@ int main(int argc, char *argv[])
 
        tevent_req_poll(req, ev);
 
-       status = wait_for_parent_recv(req);
+       status = wait_for_parent_recv(req, &err);
        if (! status) {
-               fprintf(stderr, "locking: wait_for_parent_recv() failed\n");
+               fprintf(stderr,
+                       "locking: wait_for_parent_recv() failed (%d)\n",
+                       err);
        }
 
        talloc_free(ev);