Move to MS-FSA algorithm when checking for invalid lock range.
authorJeremy Allison <jra@samba.org>
Wed, 5 May 2010 22:57:57 +0000 (15:57 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 5 May 2010 22:57:57 +0000 (15:57 -0700)
Satisfies SMB and SMB2.

Jeremy.

source3/locking/brlock.c
source3/smbd/smb2_lock.c

index ee0eaf5198bf59896359312fd4c440582ea0f34e..8250e5a9d4ceff81c55f72ea776bc4dea073d6a6 100644 (file)
@@ -333,12 +333,12 @@ NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
 
        SMB_ASSERT(plock->lock_type != UNLOCK_LOCK);
 
-       for (i=0; i < br_lck->num_locks; i++) {
-               if (locks[i].start + locks[i].size < locks[i].start) {
-                       /* 64-bit wrap. Error. */
-                       return NT_STATUS_INVALID_LOCK_RANGE;
-               }
+       if ((plock->start + plock->size - 1 < plock->start) &&
+                       plock->size != 0) {
+               return NT_STATUS_INVALID_LOCK_RANGE;
+       }
 
+       for (i=0; i < br_lck->num_locks; i++) {
                /* Do any Windows or POSIX locks conflict ? */
                if (brl_conflict(&locks[i], plock)) {
                        /* Remember who blocked us. */
@@ -716,8 +716,7 @@ static NTSTATUS brl_lock_posix(struct messaging_context *msg_ctx,
        }
 
        /* Don't allow 64-bit lock wrap. */
-       if (plock->start + plock->size < plock->start ||
-                       plock->start + plock->size < plock->size) {
+       if (plock->start + plock->size - 1 < plock->start) {
                return NT_STATUS_INVALID_PARAMETER;
        }
 
index 9e699159ff060f6753cdaa8728d6ce70f660224c..7b01889c4609ff0107aa1fef025fb6b401ad2267 100644 (file)
@@ -277,7 +277,6 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
        }
 
        for (i=0; i<in_lock_count; i++) {
-               uint64_t max_count;
                bool invalid = false;
 
                switch (in_locks[i].flags) {
@@ -346,12 +345,6 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
                } else {
                        locks[i].brltype = UNLOCK_LOCK;
                }
-
-               max_count = UINT64_MAX - locks[i].offset;
-               if (locks[i].count > max_count) {
-                       tevent_req_nterror(req, NT_STATUS_INVALID_LOCK_RANGE);
-                       return tevent_req_post(req, ev);
-               }
        }
 
        state->locks = locks;