From: Stefan Metzmacher Date: Fri, 26 Aug 2022 09:17:51 +0000 (+0200) Subject: s3:locking: let set_write_time() use share_mode_lock_access_private_data() X-Git-Tag: talloc-2.4.0~884 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db0e67329297e34ade2062e73ec023a6d46efb00;p=thirdparty%2Fsamba.git s3:locking: let set_write_time() 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 --- diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 7a6b1c8b571..eb7b8f6c23c 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -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);