]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:locking: let get_share_mode_write_time() 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 eb7b8f6c23c09430268822185dc8aac51ea31f50..cf96d9bb13a16cd936e3baccba5e7bdd2a40384f 100644 (file)
@@ -1130,7 +1130,22 @@ bool set_write_time(struct file_id fileid, struct timespec write_time)
 
 struct timespec get_share_mode_write_time(struct share_mode_lock *lck)
 {
-       struct share_mode_data *d = lck->data;
+       struct share_mode_data *d = NULL;
+       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;
+               struct timespec ts_zero = {};
+               /* Any error recovery possible here ? */
+               DBG_ERR("share_mode_lock_access_private_data() failed for "
+                       "%s - %s\n",
+                       file_id_str_buf(id, &id_buf),
+                       nt_errstr(status));
+               smb_panic(__location__);
+               return ts_zero;
+       }
 
        if (!null_nttime(d->changed_write_time)) {
                return nt_time_to_full_timespec(d->changed_write_time);