auth: Slightly simplify smb_pwd_check_ntlmv1()
authorVolker Lendecke <vl@samba.org>
Fri, 3 Jan 2020 13:10:00 +0000 (14:10 +0100)
committerGary Lockyer <gary@samba.org>
Mon, 6 Jan 2020 01:47:30 +0000 (01:47 +0000)
Do an early return for the failure case

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
libcli/auth/ntlm_check.c

index 3e00901b166b6766f61ba6a7312db74d41ad580d..11d75b31010e6f65099c960139cac02dfb53f242 100644 (file)
@@ -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;
 }
 
 /****************************************************************************