From 2e7ccb72a075f39ea6a406cba0ae53a1fd5314ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 26 Aug 2022 11:17:51 +0200 Subject: [PATCH] s3:locking: let set_delete_on_close_lck() use share_mode_lock_access_private_data() 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 Reviewed-by: Jeremy Allison --- source3/locking/locking.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 42880f7ce1c..3a33f7de4ea 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -881,13 +881,23 @@ void set_delete_on_close_lck(files_struct *fsp, const struct security_token *nt_tok, const struct security_unix_token *tok) { - struct share_mode_data *d = lck->data; + struct share_mode_data *d = NULL; struct set_delete_on_close_state state = { .msg_ctx = fsp->conn->sconn->msg_ctx }; uint32_t i; bool ret; enum ndr_err_code ndr_err; + NTSTATUS status; + + status = share_mode_lock_access_private_data(lck, &d); + if (!NT_STATUS_IS_OK(status)) { + /* Any error recovery possible here ? */ + DBG_ERR("share_mode_lock_access_private_data() failed for " + "%s - %s\n", fsp_str_dbg(fsp), nt_errstr(status)); + smb_panic(__location__); + return; + } SMB_ASSERT(nt_tok != NULL); SMB_ASSERT(tok != NULL); @@ -909,7 +919,7 @@ void set_delete_on_close_lck(files_struct *fsp, } } - ret = add_delete_on_close_token(lck->data, fsp->name_hash, nt_tok, tok); + ret = add_delete_on_close_token(d, fsp->name_hash, nt_tok, tok); SMB_ASSERT(ret); ndr_err = ndr_push_struct_blob( -- 2.11.4.GIT