From 6d3399906fe56cb0bd5245bfefb94391bbd0d32c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Apr 2020 15:59:09 +0200 Subject: [PATCH] smbd: Make sure share_mode_entry_do() maintains sorting order Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/locking/share_mode_lock.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index e66c375a142..183a1e55234 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -1962,7 +1962,17 @@ static void share_mode_entry_do_fn( } if (!e.stale) { - bool ok = share_mode_entry_put(&e, &buf); + bool ok; + + if (state->num_share_modes != 1) { + /* + * Make sure the sorting order stays intact + */ + SMB_ASSERT(server_id_equal(&e.pid, &state->pid)); + SMB_ASSERT(e.share_file_id == state->share_file_id); + } + + ok = share_mode_entry_put(&e, &buf); if (!ok) { DBG_DEBUG("share_mode_entry_put failed\n"); state->status = NT_STATUS_INTERNAL_ERROR; -- 2.47.3