Skip to content

Commit

Permalink
KCM: sss_iobuf_init_empty() shall not zero memory
Browse files Browse the repository at this point in the history
sss_iobuf_init_empty() and related functions zero the allocated memory
even though it is not needed. Most of the time, all the fields in the
structures will be set to non-zero values. In these cases zeroing the
is useless and we stop doing it.

Only in two cases, some pointers were being left unmodified, so they
are now being manually set to NULL.

Resolves: SSSD#7014
  • Loading branch information
aplopez committed Nov 13, 2023
1 parent 1491463 commit 80934c8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion src/responder/kcm/kcmsrv_ccache.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ struct kcm_cred *kcm_cred_new(TALLOC_CTX *mem_ctx,
if (kcreds == NULL) {
return NULL;
}

uuid_copy(kcreds->uuid, uuid);
kcreds->cred_blob = talloc_steal(kcreds, cred_blob);
return kcreds;
Expand Down
4 changes: 1 addition & 3 deletions src/util/sss_iobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct sss_iobuf *sss_iobuf_init_empty(TALLOC_CTX *mem_ctx,
return NULL;
}

buf = talloc_zero_array(iobuf, uint8_t, size);
buf = talloc_array(iobuf, uint8_t, size);
if (buf == NULL) {
talloc_free(iobuf);
return NULL;
Expand All @@ -43,7 +43,6 @@ struct sss_iobuf *sss_iobuf_init_empty(TALLOC_CTX *mem_ctx,
iobuf->data = buf;
iobuf->size = size;
iobuf->capacity = capacity;
iobuf->dp = 0;

return iobuf;
}
Expand Down Expand Up @@ -80,7 +79,6 @@ struct sss_iobuf *sss_iobuf_init_steal(TALLOC_CTX *mem_ctx,
iobuf->data = talloc_steal(iobuf, data);
iobuf->size = size;
iobuf->capacity = size;
iobuf->dp = 0;

return iobuf;
}
Expand Down

0 comments on commit 80934c8

Please sign in to comment.