]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:locking: let set_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 7a6b1c8b57123f674be62a31658ad11202b24692..eb7b8f6c23c09430268822185dc8aac51ea31f50 100644 (file)
@@ -1093,9 +1093,11 @@ bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
 bool set_write_time(struct file_id fileid, struct timespec write_time)
 {
        struct share_mode_lock *lck;
+       struct share_mode_data *d = NULL;
        struct file_id_buf idbuf;
        struct timeval_buf tbuf;
        NTTIME nt = full_timespec_to_nt_time(&write_time);
+       NTSTATUS status;
 
        DBG_INFO("%s id=%s\n",
                 timespec_string_buf(&write_time, true, &tbuf),
@@ -1106,9 +1108,20 @@ bool set_write_time(struct file_id fileid, struct timespec write_time)
                return False;
        }
 
-       if (lck->data->old_write_time != nt) {
-               lck->data->modified = True;
-               lck->data->old_write_time = nt;
+       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 id=%s - %s\n",
+                       timespec_string_buf(&write_time, true, &tbuf),
+                       file_id_str_buf(fileid, &idbuf),
+                       nt_errstr(status));
+               return false;
+       }
+
+       if (d->old_write_time != nt) {
+               d->modified = True;
+               d->old_write_time = nt;
        }
 
        TALLOC_FREE(lck);