diff options
author | Volker Lendecke <vl@samba.org> | 2020-01-03 14:10:00 +0100 |
---|---|---|
committer | Gary Lockyer <gary@samba.org> | 2020-01-06 01:47:30 +0000 |
commit | b78cc8210d3fe75af5236a16841060bbcc553cde (patch) | |
tree | 4abb24a4daa79923fe0336a450287194c0a9d351 /libcli/auth | |
parent | 8ec4e4b668d009f9c79ce324dce0d512e16d4cb9 (diff) | |
download | samba-b78cc8210d3fe75af5236a16841060bbcc553cde.tar.gz |
auth: Slightly simplify smb_pwd_check_ntlmv2()
Do an early return for the failure case
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'libcli/auth')
-rw-r--r-- | libcli/auth/ntlm_check.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/libcli/auth/ntlm_check.c b/libcli/auth/ntlm_check.c index 6e25ca280ef..03288847628 100644 --- a/libcli/auth/ntlm_check.c +++ b/libcli/auth/ntlm_check.c @@ -98,6 +98,7 @@ static bool smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx, uint8_t value_from_encryption[16]; DATA_BLOB client_key_data; NTSTATUS status; + bool ok; if (part_passwd == NULL) { DEBUG(10,("No password set - DISALLOWING access\n")); @@ -151,24 +152,25 @@ static bool smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx, dump_data(100, value_from_encryption, 16); #endif data_blob_clear_free(&client_key_data); - if (memcmp(value_from_encryption, ntv2_response->data, 16) == 0) { - if (user_sess_key != NULL) { - *user_sess_key = data_blob_talloc(mem_ctx, NULL, 16); - if (user_sess_key->data == NULL) { - DBG_ERR("data_blob_talloc failed\n"); - return false; - } - status = SMBsesskeygen_ntv2(kr, - value_from_encryption, - user_sess_key->data); - if (!NT_STATUS_IS_OK(status)) { - return false; - } + ok = (memcmp(value_from_encryption, ntv2_response->data, 16) == 0); + if (!ok) { + return false; + } + if (user_sess_key != NULL) { + *user_sess_key = data_blob_talloc(mem_ctx, NULL, 16); + if (user_sess_key->data == NULL) { + DBG_ERR("data_blob_talloc failed\n"); + return false; + } + + status = SMBsesskeygen_ntv2( + kr, value_from_encryption, user_sess_key->data); + if (!NT_STATUS_IS_OK(status)) { + return false; } - return true; } - return false; + return true; } /**************************************************************************** |