1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

netlogon_creds_cli: Simplify netlogon_creds_cli_store

Don't implicitly TALLOC_FREE(creds) in the pure store routine. This
mixes up responsibilities, and there's not enough callers to justify
the TALLOC_FREE to be centralized.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Volker Lendecke 2017-09-10 14:55:13 +02:00
parent c234599a54
commit 154b28b686
2 changed files with 18 additions and 17 deletions

View File

@ -672,21 +672,17 @@ bool netlogon_creds_cli_validate(struct netlogon_creds_cli_context *context,
} }
NTSTATUS netlogon_creds_cli_store(struct netlogon_creds_cli_context *context, NTSTATUS netlogon_creds_cli_store(struct netlogon_creds_cli_context *context,
struct netlogon_creds_CredentialState **_creds) struct netlogon_creds_CredentialState *creds)
{ {
struct netlogon_creds_CredentialState *creds = *_creds;
NTSTATUS status; NTSTATUS status;
enum ndr_err_code ndr_err; enum ndr_err_code ndr_err;
DATA_BLOB blob; DATA_BLOB blob;
TDB_DATA data; TDB_DATA data;
*_creds = NULL;
if (context->db.locked_state == NULL) { if (context->db.locked_state == NULL) {
/* /*
* this was not the result of netlogon_creds_cli_lock*() * this was not the result of netlogon_creds_cli_lock*()
*/ */
TALLOC_FREE(creds);
return NT_STATUS_INVALID_PAGE_PROTECTION; return NT_STATUS_INVALID_PAGE_PROTECTION;
} }
@ -694,14 +690,12 @@ NTSTATUS netlogon_creds_cli_store(struct netlogon_creds_cli_context *context,
/* /*
* this was not the result of netlogon_creds_cli_lock*() * this was not the result of netlogon_creds_cli_lock*()
*/ */
TALLOC_FREE(creds);
return NT_STATUS_INVALID_PAGE_PROTECTION; return NT_STATUS_INVALID_PAGE_PROTECTION;
} }
ndr_err = ndr_push_struct_blob(&blob, creds, creds, ndr_err = ndr_push_struct_blob(&blob, creds, creds,
(ndr_push_flags_fn_t)ndr_push_netlogon_creds_CredentialState); (ndr_push_flags_fn_t)ndr_push_netlogon_creds_CredentialState);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
TALLOC_FREE(creds);
status = ndr_map_error2ntstatus(ndr_err); status = ndr_map_error2ntstatus(ndr_err);
return status; return status;
} }
@ -712,7 +706,7 @@ NTSTATUS netlogon_creds_cli_store(struct netlogon_creds_cli_context *context,
status = dbwrap_store(context->db.ctx, status = dbwrap_store(context->db.ctx,
context->db.key_data, context->db.key_data,
data, TDB_REPLACE); data, TDB_REPLACE);
TALLOC_FREE(creds); TALLOC_FREE(data.dptr);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
return status; return status;
} }
@ -1666,8 +1660,8 @@ static void netlogon_creds_cli_check_caps(struct tevent_req *subreq)
*state->creds = state->tmp_creds; *state->creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->creds); state->creds);
netlogon_creds_cli_check_cleanup(req, status); TALLOC_FREE(state->creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
return; return;
} }
@ -2018,7 +2012,8 @@ static void netlogon_creds_cli_ServerPasswordSet_done(struct tevent_req *subreq)
*state->creds = state->tmp_creds; *state->creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->creds); state->creds);
TALLOC_FREE(state->creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
netlogon_creds_cli_ServerPasswordSet_cleanup(req, status); netlogon_creds_cli_ServerPasswordSet_cleanup(req, status);
return; return;
@ -2514,7 +2509,9 @@ static void netlogon_creds_cli_LogonSamLogon_done(struct tevent_req *subreq)
*state->lk_creds = state->tmp_creds; *state->lk_creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->lk_creds); state->lk_creds);
TALLOC_FREE(state->lk_creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
netlogon_creds_cli_LogonSamLogon_cleanup(req, status); netlogon_creds_cli_LogonSamLogon_cleanup(req, status);
return; return;
@ -2811,7 +2808,8 @@ static void netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_done(struct tev
*state->creds = state->tmp_creds; *state->creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->creds); state->creds);
TALLOC_FREE(state->creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_cleanup(req, status); netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_cleanup(req, status);
@ -3077,7 +3075,8 @@ static void netlogon_creds_cli_ServerGetTrustInfo_done(struct tevent_req *subreq
*state->creds = state->tmp_creds; *state->creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->creds); state->creds);
TALLOC_FREE(state->creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
netlogon_creds_cli_ServerGetTrustInfo_cleanup(req, status); netlogon_creds_cli_ServerGetTrustInfo_cleanup(req, status);
return; return;
@ -3359,7 +3358,8 @@ static void netlogon_creds_cli_GetForestTrustInformation_done(struct tevent_req
*state->creds = state->tmp_creds; *state->creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->creds); state->creds);
TALLOC_FREE(state->creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
netlogon_creds_cli_GetForestTrustInformation_cleanup(req, status); netlogon_creds_cli_GetForestTrustInformation_cleanup(req, status);
@ -3638,7 +3638,8 @@ static void netlogon_creds_cli_SendToSam_done(struct tevent_req *subreq)
*state->creds = state->tmp_creds; *state->creds = state->tmp_creds;
status = netlogon_creds_cli_store(state->context, status = netlogon_creds_cli_store(state->context,
&state->creds); state->creds);
TALLOC_FREE(state->creds);
if (tevent_req_nterror(req, status)) { if (tevent_req_nterror(req, status)) {
netlogon_creds_cli_SendToSam_cleanup(req, status); netlogon_creds_cli_SendToSam_cleanup(req, status);

View File

@ -68,7 +68,7 @@ bool netlogon_creds_cli_validate(struct netlogon_creds_cli_context *context,
const struct netlogon_creds_CredentialState *creds1); const struct netlogon_creds_CredentialState *creds1);
NTSTATUS netlogon_creds_cli_store(struct netlogon_creds_cli_context *context, NTSTATUS netlogon_creds_cli_store(struct netlogon_creds_cli_context *context,
struct netlogon_creds_CredentialState **_creds); struct netlogon_creds_CredentialState *creds);
NTSTATUS netlogon_creds_cli_delete(struct netlogon_creds_cli_context *context, NTSTATUS netlogon_creds_cli_delete(struct netlogon_creds_cli_context *context,
struct netlogon_creds_CredentialState **_creds); struct netlogon_creds_CredentialState **_creds);