s3:locking: let get_delete_on_close_token() use share_mode_lock_access_private_data()
authorStefan Metzmacher <metze@samba.org>
Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 20 Sep 2022 00:34:35 +0000 (00:34 +0000)
We should avoid dereference 'struct share_mode_lock' as much as possible.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/locking.c

index 3a33f7de4ea5c319134fa2626f33c39bbc61e7ec..f4ed19bb35f9a47b30dbbe18b0157ac57fe9d977 100644 (file)
@@ -1007,9 +1007,23 @@ bool get_delete_on_close_token(struct share_mode_lock *lck,
                                        const struct security_token **pp_nt_tok,
                                        const struct security_unix_token **pp_tok)
 {
+       struct share_mode_data *d = NULL;
        struct delete_token *dt;
+       NTSTATUS status;
+
+       status = share_mode_lock_access_private_data(lck, &d);
+       if (!NT_STATUS_IS_OK(status)) {
+               struct file_id id = share_mode_lock_file_id(lck);
+               struct file_id_buf id_buf;
+               /* Any error recovery possible here ? */
+               DBG_ERR("share_mode_lock_access_private_data() failed for "
+                       "%s name_hash=%"PRIu32" - %s\n",
+                       file_id_str_buf(id, &id_buf), name_hash,
+                       nt_errstr(status));
+               return false;
+       }
 
-       dt = find_delete_on_close_token(lck->data, name_hash);
+       dt = find_delete_on_close_token(d, name_hash);
        if (dt == NULL) {
                return false;
        }