s3: smbd: Locking, fix off-by one calculation in brl_pending_overlap().
authorJeremy Allison <jra@samba.org>
Tue, 1 Jul 2014 20:30:50 +0000 (13:30 -0700)
committerMichael Adam <obnox@samba.org>
Wed, 2 Jul 2014 08:18:17 +0000 (10:18 +0200)
Consider:

lock = start=110,size=10
pend_lock = 100, size=10

Do not overlap. However,

(lock->start <= pend_lock->start + pend_lock->size)
     110             100                10

is true, so it returns true (overlap).

lock->start <= pend_lock->start + pend_lock->size

should be:

lock->start < pend_lock->start + pend_lock->size

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10685

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Jul  2 10:18:17 CEST 2014 on sn-devel-104

source3/locking/brlock.c

index e134aacd9b4ee9dd872cef463f0eb53ba0da2b21..2ab70929f3fc1d308cea7d4f72607d62fdb21fa0 100644 (file)
@@ -263,7 +263,7 @@ static bool brl_pending_overlap(const struct lock_struct *lock, const struct loc
 {
        if ((lock->start <= pend_lock->start) && (lock->start + lock->size > pend_lock->start))
                return True;
-       if ((lock->start >= pend_lock->start) && (lock->start <= pend_lock->start + pend_lock->size))
+       if ((lock->start >= pend_lock->start) && (lock->start < pend_lock->start + pend_lock->size))
                return True;
        return False;
 }