mirror of
https://github.com/samba-team/samba.git
synced 2025-10-21 03:33:16 +03:00
lib: Use talloc_realloc_zero() in a few obvious places
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
This commit is contained in:
@@ -553,16 +553,13 @@ static bool ad_pack_xattrs(struct vfs_handle_struct *handle,
|
||||
|
||||
oldsize = talloc_get_size(ad->ad_data);
|
||||
if (oldsize < AD_XATTR_MAX_HDR_SIZE) {
|
||||
ad->ad_data = talloc_realloc(ad,
|
||||
ad->ad_data,
|
||||
char,
|
||||
AD_XATTR_MAX_HDR_SIZE);
|
||||
ad->ad_data = talloc_realloc_zero(ad,
|
||||
ad->ad_data,
|
||||
char,
|
||||
AD_XATTR_MAX_HDR_SIZE);
|
||||
if (ad->ad_data == NULL) {
|
||||
return false;
|
||||
}
|
||||
memset(ad->ad_data + oldsize,
|
||||
0,
|
||||
AD_XATTR_MAX_HDR_SIZE - oldsize);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -2871,12 +2871,14 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
|
||||
}
|
||||
|
||||
/* Make sure to NULL terminate the array */
|
||||
spn_array = talloc_realloc(ctx, spn_array, const char *, num_spns + 1);
|
||||
spn_array = talloc_realloc_zero(ctx,
|
||||
spn_array,
|
||||
const char *,
|
||||
num_spns + 1);
|
||||
if (spn_array == NULL) {
|
||||
ret = ADS_ERROR(LDAP_NO_MEMORY);
|
||||
goto done;
|
||||
}
|
||||
spn_array[num_spns] = NULL;
|
||||
|
||||
controlstr = talloc_asprintf(ctx, "%u", acct_control);
|
||||
if (controlstr == NULL) {
|
||||
|
@@ -373,18 +373,16 @@ static bool smbprofile_persvc_grow(int snum)
|
||||
}
|
||||
|
||||
new_cap = (size_t)snum + 1;
|
||||
new_tbl = talloc_realloc(NULL,
|
||||
smbprofile_state.persvc.tbl,
|
||||
struct profile_stats_persvc *,
|
||||
new_cap);
|
||||
new_tbl = talloc_realloc_zero(NULL,
|
||||
smbprofile_state.persvc.tbl,
|
||||
struct profile_stats_persvc *,
|
||||
new_cap);
|
||||
|
||||
if (new_tbl == NULL) {
|
||||
DBG_ERR("Failed to realloc persvc table for snum %d\n", snum);
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(&new_tbl[cur_cap], 0, (new_cap - cur_cap) * sizeof(*new_tbl));
|
||||
|
||||
smbprofile_state.persvc.tbl = new_tbl;
|
||||
return true;
|
||||
}
|
||||
|
@@ -317,10 +317,10 @@ static bool get_trusted_domains(struct torture_context *torture,
|
||||
while (next_token_talloc(torture, &extra_data, &line, "\n")) {
|
||||
char *p, *lp;
|
||||
|
||||
d = talloc_realloc(torture, d,
|
||||
struct torture_trust_domain,
|
||||
dcount + 2);
|
||||
ZERO_STRUCT(d[dcount+1]);
|
||||
d = talloc_realloc_zero(torture,
|
||||
d,
|
||||
struct torture_trust_domain,
|
||||
dcount + 2);
|
||||
|
||||
lp = line;
|
||||
p = strchr(lp, '\\');
|
||||
@@ -646,8 +646,7 @@ static bool get_user_list(struct torture_context *torture, char ***users)
|
||||
next_token_talloc(torture, &extra_data, &name, ",");
|
||||
count++)
|
||||
{
|
||||
u = talloc_realloc(torture, u, char *, count + 2);
|
||||
u[count+1] = NULL;
|
||||
u = talloc_realloc_zero(torture, u, char *, count + 2);
|
||||
u[count] = talloc_move(u, &name);
|
||||
}
|
||||
|
||||
@@ -707,8 +706,7 @@ static bool get_group_list(struct torture_context *torture,
|
||||
next_token_talloc(torture, &extra_data, &name, ",");
|
||||
count++)
|
||||
{
|
||||
g = talloc_realloc(torture, g, char *, count + 2);
|
||||
g[count+1] = NULL;
|
||||
g = talloc_realloc_zero(torture, g, char *, count + 2);
|
||||
g[count] = talloc_move(g, &name);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user