Skip to content

Commit

Permalink
KCM: Do not zero memory when not need.
Browse files Browse the repository at this point in the history
A few more cases where memory is allocated and zeroed when it is not
required.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Tomáš Halman <thalman@redhat.com>
(cherry picked from commit b4f9f63)
  • Loading branch information
aplopez authored and pbrezina committed Nov 28, 2023
1 parent 78d0a97 commit 60fde9d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/responder/kcm/kcmsrv_ccache.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ krb5_creds **kcm_cc_unmarshal(TALLOC_CTX *mem_ctx,
count++;
}

cred_list = talloc_zero_array(tmp_ctx, krb5_creds *, count + 1);
cred_list = talloc_array(tmp_ctx, krb5_creds *, count + 1);

for (cred = kcm_cc_get_cred(cc); cred != NULL; cred = kcm_cc_next_cred(cred), i++) {
cred_list[i] = kcm_cred_to_krb5(krb_context, cred);
Expand Down Expand Up @@ -513,7 +513,7 @@ struct kcm_ccdb *kcm_ccdb_init(TALLOC_CTX *mem_ctx,
ccdb->ops = &ccdb_secdb_ops;
break;
default:
DEBUG(SSSDBG_CRIT_FAILURE, "Unknown ccache database\n");
DEBUG(SSSDBG_CRIT_FAILURE, "Unknown ccache database backend\n");
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/responder/kcm/kcmsrv_ccache_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static errno_t bin_to_princ(TALLOC_CTX *mem_ctx,
return ret;
}

princ->data = talloc_zero_array(princ, krb5_data, princ->length);
princ->data = talloc_array(princ, krb5_data, princ->length);
if (princ->length > 0 && princ->data == NULL) {
return ENOMEM;
}
Expand Down
4 changes: 2 additions & 2 deletions src/responder/kcm/kcmsrv_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static errno_t kcm_output_construct(TALLOC_CTX *mem_ctx,
SAFEALIGN_SETMEM_UINT32(repbuf->rcbuf, 0, &c);

if (replen > 0) {
rep = talloc_zero_array(mem_ctx, uint8_t, replen);
rep = talloc_array(mem_ctx, uint8_t, replen);
if (rep == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Failed to allocate memory for the message\n");
Expand Down Expand Up @@ -437,7 +437,7 @@ static errno_t kcm_recv_data(TALLOC_CTX *mem_ctx,
return E2BIG;
}

msg = talloc_zero_array(mem_ctx, uint8_t, msglen);
msg = talloc_array(mem_ctx, uint8_t, msglen);
if (msg == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Failed to allocate memory for the message\n");
Expand Down

0 comments on commit 60fde9d

Please sign in to comment.