mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Move to MS-FSA algorithm when checking for invalid lock range.
Satisfies SMB and SMB2. Jeremy.
This commit is contained in:
parent
c6ebab846d
commit
d58b795587
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user