From 14cc4a65767ea069e0ad03bb423f84f66a9e41ca Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 24 Apr 2020 09:14:55 +0200 Subject: [PATCH] smbd: Make parse_share_modes() use a const ptr Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/locking/share_mode_lock.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index e72b7215e50..c7940aa4c19 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -373,19 +373,18 @@ static struct share_mode_data *share_mode_memcache_fetch( Get all share mode entries for a dev/inode pair. ********************************************************************/ -static struct share_mode_data *parse_share_modes(TALLOC_CTX *mem_ctx, - const TDB_DATA key, - const TDB_DATA dbuf) +static struct share_mode_data *parse_share_modes( + TALLOC_CTX *mem_ctx, + const TDB_DATA key, + const uint8_t *buf, + size_t buflen) { struct share_mode_data *d; enum ndr_err_code ndr_err; DATA_BLOB blob; - blob.data = dbuf.dptr; - blob.length = dbuf.dsize; - /* See if we already have a cached copy of this key. */ - d = share_mode_memcache_fetch(mem_ctx, key, dbuf.dptr, dbuf.dsize); + d = share_mode_memcache_fetch(mem_ctx, key, buf, buflen); if (d != NULL) { return d; } @@ -396,6 +395,10 @@ static struct share_mode_data *parse_share_modes(TALLOC_CTX *mem_ctx, goto fail; } + blob = (DATA_BLOB) { + .data = discard_const_p(uint8_t, buf), + .length = buflen, + }; ndr_err = ndr_pull_struct_blob_all( &blob, d, d, (ndr_pull_flags_fn_t)ndr_pull_share_mode_data); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -578,7 +581,7 @@ static NTSTATUS get_static_share_mode_data( } } else { TDB_DATA key = locking_key(&id); - d = parse_share_modes(lock_db, key, value); + d = parse_share_modes(lock_db, key, value.dptr, value.dsize); if (d == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -927,7 +930,8 @@ static void fetch_share_mode_unlocked_parser( return; } - state->lck->data = parse_share_modes(state->lck, key, data); + state->lck->data = parse_share_modes( + state->lck, key, data.dptr, data.dsize); } /******************************************************************* -- 2.47.3