]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
auth: Reduce indentation
authorVolker Lendecke <vl@samba.org>
Thu, 3 Apr 2025 15:14:42 +0000 (17:14 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 15 May 2025 14:03:34 +0000 (14:03 +0000)
Best reviewed with "git sh -b"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
auth/credentials/credentials_ntlm.c

index a018be14c56b2377013573e1d330eabe7191ceb7..002ce4bd06042c7f8fc9c362811f55b4c7c072e8 100644 (file)
@@ -353,47 +353,47 @@ _PUBLIC_ bool cli_credentials_set_utf16_password(struct cli_credentials *cred,
                                                 const DATA_BLOB *password_utf16,
                                                 enum credentials_obtained obtained)
 {
+       struct samr_Password *nt_hash = NULL;
+       char *password_talloc = NULL;
+       size_t password_len = 0;
+       bool ok;
+
        cred->password_will_be_nt_hash = false;
 
        if (password_utf16 == NULL) {
                return cli_credentials_set_password(cred, NULL, obtained);
        }
 
-       if (obtained >= cred->password_obtained) {
-               struct samr_Password *nt_hash = NULL;
-               char *password_talloc = NULL;
-               size_t password_len = 0;
-               bool ok;
-
-               nt_hash = talloc(cred, struct samr_Password);
-               if (nt_hash == NULL) {
-                       return false;
-               }
+       if (obtained < cred->password_obtained) {
+               return false;
+       }
 
-               ok = convert_string_talloc(cred,
-                                          CH_UTF16MUNGED, CH_UTF8,
-                                          password_utf16->data,
-                                          password_utf16->length,
-                                          &password_talloc,
-                                          &password_len);
-               if (!ok) {
-                       TALLOC_FREE(nt_hash);
-                       return false;
-               }
+       nt_hash = talloc(cred, struct samr_Password);
+       if (nt_hash == NULL) {
+               return false;
+       }
 
-               ok = cli_credentials_set_password(cred, password_talloc, obtained);
-               TALLOC_FREE(password_talloc);
-               if (!ok) {
-                       TALLOC_FREE(nt_hash);
-                       return false;
-               }
+       ok = convert_string_talloc(cred,
+                                  CH_UTF16MUNGED, CH_UTF8,
+                                  password_utf16->data,
+                                  password_utf16->length,
+                                  &password_talloc,
+                                  &password_len);
+       if (!ok) {
+               TALLOC_FREE(nt_hash);
+               return false;
+       }
 
-               mdfour(nt_hash->hash, password_utf16->data, password_utf16->length);
-               cred->nt_hash = nt_hash;
-               return true;
+       ok = cli_credentials_set_password(cred, password_talloc, obtained);
+       TALLOC_FREE(password_talloc);
+       if (!ok) {
+               TALLOC_FREE(nt_hash);
+               return false;
        }
 
-       return false;
+       mdfour(nt_hash->hash, password_utf16->data, password_utf16->length);
+       cred->nt_hash = nt_hash;
+       return true;
 }
 
 /*
@@ -469,21 +469,21 @@ _PUBLIC_ bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
 {
        cred->password_will_be_nt_hash = false;
 
-       if (obtained >= cred->password_obtained) {
-               cli_credentials_set_password(cred, NULL, obtained);
-               if (nt_hash) {
-                       cred->nt_hash = talloc(cred, struct samr_Password);
-                       if (cred->nt_hash == NULL) {
-                               return false;
-                       }
-                       *cred->nt_hash = *nt_hash;
-               } else {
-                       cred->nt_hash = NULL;
-               }
-               return true;
+       if (obtained < cred->password_obtained) {
+               return false;
        }
 
-       return false;
+       cli_credentials_set_password(cred, NULL, obtained);
+       if (nt_hash) {
+               cred->nt_hash = talloc(cred, struct samr_Password);
+               if (cred->nt_hash == NULL) {
+                       return false;
+               }
+               *cred->nt_hash = *nt_hash;
+       } else {
+               cred->nt_hash = NULL;
+       }
+       return true;
 }
 
 _PUBLIC_ bool cli_credentials_set_old_nt_hash(struct cli_credentials *cred,
@@ -510,51 +510,51 @@ _PUBLIC_ bool cli_credentials_set_ntlm_response(struct cli_credentials *cred,
                                                const DATA_BLOB *nt_session_key,
                                                enum credentials_obtained obtained)
 {
-       if (obtained >= cred->password_obtained) {
-               cli_credentials_set_password(cred, NULL, obtained);
-
-               data_blob_clear_free(&cred->lm_response);
-               data_blob_clear_free(&cred->lm_session_key);
-               data_blob_clear_free(&cred->nt_response);
-               data_blob_clear_free(&cred->nt_session_key);
-
-               if (lm_response != NULL && lm_response->length != 0) {
-                       cred->lm_response = data_blob_talloc(cred,
-                                                       lm_response->data,
-                                                       lm_response->length);
-                       if (cred->lm_response.data == NULL) {
-                               return false;
-                       }
+       if (obtained < cred->password_obtained) {
+               return false;
+       }
+
+       cli_credentials_set_password(cred, NULL, obtained);
+
+       data_blob_clear_free(&cred->lm_response);
+       data_blob_clear_free(&cred->lm_session_key);
+       data_blob_clear_free(&cred->nt_response);
+       data_blob_clear_free(&cred->nt_session_key);
+
+       if (lm_response != NULL && lm_response->length != 0) {
+               cred->lm_response = data_blob_talloc(cred,
+                                                    lm_response->data,
+                                                    lm_response->length);
+               if (cred->lm_response.data == NULL) {
+                       return false;
                }
-               if (lm_session_key != NULL && lm_session_key->length != 0) {
-                       cred->lm_session_key = data_blob_talloc(cred,
+       }
+       if (lm_session_key != NULL && lm_session_key->length != 0) {
+               cred->lm_session_key = data_blob_talloc(cred,
                                                        lm_session_key->data,
                                                        lm_session_key->length);
-                       if (cred->lm_session_key.data == NULL) {
-                               return false;
-                       }
+               if (cred->lm_session_key.data == NULL) {
+                       return false;
                }
+       }
 
-               if (nt_response != NULL && nt_response->length != 0) {
-                       cred->nt_response = data_blob_talloc(cred,
-                                                       nt_response->data,
-                                                       nt_response->length);
-                       if (cred->nt_response.data == NULL) {
-                               return false;
-                       }
+       if (nt_response != NULL && nt_response->length != 0) {
+               cred->nt_response = data_blob_talloc(cred,
+                                                    nt_response->data,
+                                                    nt_response->length);
+               if (cred->nt_response.data == NULL) {
+                       return false;
                }
-               if (nt_session_key != NULL && nt_session_key->length != 0) {
-                       cred->nt_session_key = data_blob_talloc(cred,
+       }
+       if (nt_session_key != NULL && nt_session_key->length != 0) {
+               cred->nt_session_key = data_blob_talloc(cred,
                                                        nt_session_key->data,
                                                        nt_session_key->length);
-                       if (cred->nt_session_key.data == NULL) {
-                               return false;
-                       }
+               if (cred->nt_session_key.data == NULL) {
+                       return false;
                }
-
-               return true;
        }
 
-       return false;
+       return true;
 }