From 733ae9cd95701f781d78af72015d64d3e6706f0c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 24 Apr 2020 11:07:53 +0200 Subject: [PATCH] smbd: Make share_mode_do_locked() use a const uint8_t * Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/locking/locking.c | 3 ++- source3/locking/proto.h | 3 ++- source3/locking/share_mode_lock.c | 34 ++++++++++++++++++++++--------- source3/smbd/reply.c | 5 ++++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/source3/locking/locking.c b/source3/locking/locking.c index f5426391c21..a108ebba00d 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -250,7 +250,8 @@ struct do_lock_state { }; static void do_lock_fn( - TDB_DATA value, + const uint8_t *buf, + size_t buflen, bool *modified_dependent, void *private_data) { diff --git a/source3/locking/proto.h b/source3/locking/proto.h index b7098c1e788..f4c68bc5ca4 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -144,7 +144,8 @@ bool file_has_read_lease(struct files_struct *fsp); struct db_record; NTSTATUS share_mode_do_locked( struct file_id id, - void (*fn)(TDB_DATA value, + void (*fn)(const uint8_t *buf, + size_t buflen, bool *modified_dependent, void *private_data), void *private_data); diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index c7940aa4c19..26f8da8cfb4 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -228,13 +228,16 @@ struct fsp_update_share_mode_flags_state { }; static void fsp_update_share_mode_flags_fn( - TDB_DATA value, bool *modified_dependent, void *private_data) + const uint8_t *buf, + size_t buflen, + bool *modified_dependent, + void *private_data) { struct fsp_update_share_mode_flags_state *state = private_data; uint64_t seq; state->ndr_err = get_share_mode_blob_header( - value.dptr, value.dsize, &seq, &state->share_mode_flags); + buf, buflen, &seq, &state->share_mode_flags); } static NTSTATUS fsp_update_share_mode_flags(struct files_struct *fsp) @@ -723,7 +726,8 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck) } struct share_mode_do_locked_state { - void (*fn)(TDB_DATA value, + void (*fn)(const uint8_t *buf, + size_t buflen, bool *modified_dependent, void *private_data); void *private_data; @@ -747,7 +751,10 @@ static void share_mode_do_locked_fn( SMB_ASSERT(static_share_mode_record == rec); } - state->fn(value, &modified_dependent, state->private_data); + state->fn(value.dptr, + value.dsize, + &modified_dependent, + state->private_data); if (modified_dependent) { dbwrap_watched_wakeup(rec); @@ -760,7 +767,8 @@ static void share_mode_do_locked_fn( NTSTATUS share_mode_do_locked( struct file_id id, - void (*fn)(TDB_DATA value, + void (*fn)(const uint8_t *buf, + size_t buflen, bool *modified_dependent, void *private_data), void *private_data) @@ -782,7 +790,8 @@ NTSTATUS share_mode_do_locked( return NT_STATUS_INVALID_LOCK_SEQUENCE; } - fn(static_share_mode_record_value, + fn(static_share_mode_record_value.dptr, + static_share_mode_record_value.dsize, &modified_dependent, private_data); @@ -809,9 +818,11 @@ NTSTATUS share_mode_do_locked( return NT_STATUS_OK; } -static void share_mode_wakeup_waiters_fn(TDB_DATA value, - bool *modified_dependent, - void *private_data) +static void share_mode_wakeup_waiters_fn( + const uint8_t *buf, + size_t buflen, + bool *modified_dependent, + void *private_data) { *modified_dependent = true; } @@ -834,7 +845,10 @@ struct share_mode_watch_state { }; static void share_mode_watch_fn( - TDB_DATA value, bool *modified_dependent, void *private_data) + const uint8_t *buf, + size_t buflen, + bool *modified_dependent, + void *private_data) { struct share_mode_watch_state *state = talloc_get_type_abort( private_data, struct share_mode_watch_state); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index fd4434c9008..0344668e99f 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -9069,7 +9069,10 @@ struct smbd_do_unlocking_state { }; static void smbd_do_unlocking_fn( - TDB_DATA value, bool *pmodified_dependent, void *private_data) + const uint8_t *buf, + size_t buflen, + bool *pmodified_dependent, + void *private_data) { struct smbd_do_unlocking_state *state = private_data; struct files_struct *fsp = state->fsp;