diff options
author | Volker Lendecke <vl@samba.org> | 2014-06-30 09:39:20 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-07-02 00:11:23 +0200 |
commit | 7d71e8d6575f6893b590f1a86c34541ebbb74740 (patch) | |
tree | 7bbe2f952417f82e4f9c228c6d43ec1ba367de59 /source3/smbd/smb2_lock.c | |
parent | 4709373cdf75d9a84eaaf1f23cf4bf07b8cb63c5 (diff) | |
download | samba-7d71e8d6575f6893b590f1a86c34541ebbb74740.tar.gz samba-7d71e8d6575f6893b590f1a86c34541ebbb74740.tar.xz samba-7d71e8d6575f6893b590f1a86c34541ebbb74740.zip |
smbd: Clarify smb2 lock checks
When reading the code it was not immediately clear to me how one of the
conditions in [MS-SMB2] 3.3.5.14.2 was satisfied. A separate loop to me
is clearer and given that we don't expect thousands of locks in a single
call also not significantly less efficient.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/smb2_lock.c')
-rw-r--r-- | source3/smbd/smb2_lock.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index 23b9913478..c4a40a5128 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -235,6 +235,24 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + if (!isunlock && (in_lock_count > 1)) { + + /* + * 3.3.5.14.2 says we SHOULD fail with INVALID_PARAMETER if we + * have more than one lock and one of those is blocking. + */ + + for (i=0; i<in_lock_count; i++) { + uint32_t flags = in_locks[i].flags; + + if ((flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) == 0) { + tevent_req_nterror( + req, NT_STATUS_INVALID_PARAMETER); + return tevent_req_post(req, ev); + } + } + } + for (i=0; i<in_lock_count; i++) { bool invalid = false; @@ -245,11 +263,6 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, invalid = true; break; } - if (i > 0) { - tevent_req_nterror(req, - NT_STATUS_INVALID_PARAMETER); - return tevent_req_post(req, ev); - } break; case SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY: |