s3:winbind: Refactor winbindd_dual_pam_auth_cached(), delay out variable assignment
authorSamuel Cabrero <scabrero@samba.org>
Wed, 30 Mar 2022 16:12:46 +0000 (18:12 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 8 Apr 2022 20:13:37 +0000 (20:13 +0000)
Delay the assignment of the out varible and assign it only if
returning NT_STATUS_OK, the caller does not use the returned
netr_SamInfo3 if the function does not return NT_STATUS_OK.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_pam.c

index 585173e90cf405bf2c6c83690df341c3e66439d6..5ae42d65877081a076d9fb044146a297f5366522 100644 (file)
@@ -1210,8 +1210,6 @@ static NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
                goto out;
        }
 
-       *info3 = talloc_steal(mem_ctx, my_info3);
-
        E_md4hash(state->request->data.auth.pass, new_nt_pass);
 
        dump_data_pw("new_nt_pass", new_nt_pass, NT_HASH_LEN);
@@ -1413,6 +1411,8 @@ static NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
                        goto out;
                }
 
+               *info3 = talloc_move(mem_ctx, &my_info3);
+
                result = NT_STATUS_OK;
                goto out;
        }