summaryrefslogtreecommitdiff
path: root/libcli
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-01-03 14:10:00 +0100
committerGary Lockyer <gary@samba.org>2020-01-06 01:47:30 +0000
commit4014d91b9a68aa2161421896a82d84e4211e480e (patch)
tree4085a87130ad32b4427fd4b1aa01b985dd35d4f7 /libcli
parent2bd941cc12245728b374edc0f71f5938c887a566 (diff)
downloadsamba-4014d91b9a68aa2161421896a82d84e4211e480e.tar.gz
auth: Slightly simplify smb_pwd_check_ntlmv1()
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')
-rw-r--r--libcli/auth/ntlm_check.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/libcli/auth/ntlm_check.c b/libcli/auth/ntlm_check.c
index 3e00901b166..11d75b31010 100644
--- a/libcli/auth/ntlm_check.c
+++ b/libcli/auth/ntlm_check.c
@@ -37,6 +37,7 @@ static bool smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
/* Finish the encryption of part_passwd. */
uint8_t p24[24];
int rc;
+ bool ok;
if (part_passwd == NULL) {
DEBUG(10,("No password set - DISALLOWING access\n"));
@@ -71,18 +72,19 @@ static bool smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
DEBUGADD(100,("Value from encryption was |\n"));
dump_data(100, p24, 24);
#endif
- if (memcmp(p24, nt_response->data, 24) == 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;
- }
- SMBsesskeygen_ntv1(part_passwd, user_sess_key->data);
+ ok = (memcmp(p24, nt_response->data, 24) == 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;
}
- return true;
- }
- return false;
+ SMBsesskeygen_ntv1(part_passwd, user_sess_key->data);
+ }
+ return true;
}
/****************************************************************************