From 7d71e8d6575f6893b590f1a86c34541ebbb74740 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 30 Jun 2014 09:39:20 +0000 Subject: 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 Reviewed-by: Jeremy Allison --- source3/smbd/smb2_lock.c | 23 ++++++++++++++++++----- 1 file 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 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: -- cgit