smbd: Make sure share_mode_entry_do() maintains sorting order
authorVolker Lendecke <vl@samba.org>
Mon, 27 Apr 2020 13:59:09 +0000 (15:59 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 May 2020 11:48:39 +0000 (11:48 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/locking/share_mode_lock.c

index e66c375a142ca7672230f6f925f43da4a3e6ea27..183a1e55234d6ee1812c18e27b02d64454b1909e 100644 (file)
@@ -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;