]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:locking: make sure brl_conflict_posix() is only called with 2 POSIX_LOCKS
authorRalph Boehme <slow@samba.org>
Fri, 7 Mar 2025 13:51:26 +0000 (14:51 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 7 Mar 2025 19:00:32 +0000 (19:00 +0000)
Otherwise we hit the assert if the caller is a windows lock
and the conflicting one a posix lock.

Or in the non-developer build we don't enforce the windows locking
rules.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/locking/brlock.c

index 9b42068a66c6e0fcc890a11a3f4419f478a27f0f..0c5dab193898f31ff7eaa9af7d365f05c718c230 100644 (file)
@@ -246,10 +246,8 @@ static bool brl_conflict(const struct lock_struct *lck1,
 static bool brl_conflict_posix(const struct lock_struct *lck1,
                                const struct lock_struct *lck2)
 {
-#if defined(DEVELOPER)
        SMB_ASSERT(lck1->lock_flav == POSIX_LOCK);
        SMB_ASSERT(lck2->lock_flav == POSIX_LOCK);
-#endif
 
        /* Read locks never conflict. */
        if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK) {
@@ -1276,10 +1274,10 @@ NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
                const struct lock_struct *exlock = &locks[i];
                bool conflict = False;
 
-               if (exlock->lock_flav == WINDOWS_LOCK) {
-                       conflict = brl_conflict(exlock, &lock);
-               } else {
+               if (lock_flav == POSIX_LOCK && exlock->lock_flav == POSIX_LOCK) {
                        conflict = brl_conflict_posix(exlock, &lock);
+               } else {
+                       conflict = brl_conflict(exlock, &lock);
                }
 
                if (conflict) {