return ptr;
}
+/* Return a copy of the len bytes of memory at in; set *code to 0 or ENOMEM. */
+static inline void *
+k5memdup(const void *in, size_t len, krb5_error_code *code)
+{
+ void *ptr = k5alloc(len, code);
+
+ if (ptr != NULL)
+ memcpy(ptr, in, len);
+ return ptr;
+}
+
+/* Like k5memdup, but add a final null byte. */
+static inline void *
+k5memdup0(const void *in, size_t len, krb5_error_code *code)
+{
+ void *ptr = k5alloc(len + 1, code);
+
+ if (ptr != NULL)
+ memcpy(ptr, in, len);
+ return ptr;
+}
+
krb5_error_code KRB5_CALLCONV
krb5_get_credentials_for_user(krb5_context context, krb5_flags options,
krb5_ccache ccache,
/* change the password */
- ptr = (char *) malloc(clear.length+1);
- memcpy(ptr, clear.data, clear.length);
- ptr[clear.length] = '\0';
-
+ ptr = k5memdup0(clear.data, clear.length, &ret);
ret = schpw_util_wrapper(server_handle, client, target,
(ticket->enc_part2->flags & TKT_FLG_INITIAL) != 0,
ptr, NULL, strresult, sizeof(strresult));
} else {
new_padata->pa_type = KRB5_PADATA_FX_COOKIE;
new_padata->length = cookie_padata->length;
- new_padata->contents = malloc(new_padata->length);
- if (new_padata->contents == NULL) {
- retval = ENOMEM;
+ new_padata->contents =
+ k5memdup(cookie_padata->contents, new_padata->length, &retval);
+ if (new_padata->contents == NULL)
free(new_padata);
- } else {
- memcpy(new_padata->contents, cookie_padata->contents,
- new_padata->length);
+ else
state->cookie = new_padata;
- }
}
}
if (retval == 0 && inner_body_out != NULL) {
padata->magic = KV5M_PA_DATA;
if (salttype == KRB5_KDB_SALTTYPE_AFS3) {
- padata->contents = k5alloc(salt->length + 1, &retval);
+ padata->contents = k5memdup0(salt->data, salt->length, &retval);
if (padata->contents == NULL)
goto cleanup;
- memcpy(padata->contents, salt->data, salt->length);
padata->pa_type = KRB5_PADATA_AFS3_SALT;
- padata->contents[salt->length] = '\0';
padata->length = salt->length + 1;
} else {
padata->pa_type = KRB5_PADATA_PW_SALT;
krb5_keyblock xorkeyblock;
size_t i = 0;
- xorbytes = malloc(origkey->keyblock.length);
+ xorbytes = k5memdup(origkey->keyblock.contents, origkey->keyblock.length,
+ &retval);
if (xorbytes == NULL)
- return ENOMEM;
- memcpy(xorbytes, origkey->keyblock.contents, origkey->keyblock.length);
+ return retval;
for (i = 0; i < origkey->keyblock.length; i++)
xorbytes[i] ^= 0xf0;
krb5_crypto_iov *hash_iov = NULL, iov;
size_t blocksize = ctp->enc->block_size, hashsize = ctp->hash->hashsize;
- plaintext = k5alloc(input->length, &ret);
+ plaintext = k5memdup(input->data, input->length, &ret);
if (plaintext == NULL)
return ret;
/* Decrypt the input checksum. */
iov.flags = KRB5_CRYPTO_TYPE_DATA;
iov.data = make_data(plaintext, input->length);
- memcpy(plaintext, input->data, input->length);
ret = ctp->enc->decrypt(xorkey, NULL, &iov, 1);
if (ret != 0)
goto cleanup;
dkent = malloc(sizeof(*dkent));
if (dkent == NULL)
goto cleanup;
- data = malloc(constant->length);
+ data = k5memdup(constant->data, constant->length, &ret);
if (data == NULL)
goto cleanup;
ret = krb5_k_create_key(NULL, dkeyblock, &dkey);
goto cleanup;
/* Add the new entry to the list. */
- memcpy(data, constant->data, constant->length);
dkent->dkey = dkey;
dkent->constant.data = data;
dkent->constant.length = constant->length;
/* Save the checksum, then zero it out in the plaintext. */
checksum = make_data(header->data.data + enc->block_size, hash->hashsize);
- saved_checksum = k5alloc(hash->hashsize, &ret);
+ saved_checksum = k5memdup(checksum.data, checksum.length, &ret);
if (saved_checksum == NULL)
goto cleanup;
- memcpy(saved_checksum, checksum.data, checksum.length);
memset(checksum.data, 0, checksum.length);
/*
return GSS_S_FAILURE;
}
- user = k5alloc(local_user->length + 1, &code);
+ user = k5memdup0(local_user->value, local_user->length, &code);
if (user == NULL) {
*minor = code;
krb5_free_context(context);
return GSS_S_FAILURE;
}
- memcpy(user, local_user->value, local_user->length);
- user[local_user->length] = '\0';
-
user_ok = krb5_kuserok(context, kname->princ, user);
free(user);
}
/* Decode token. */
- copy = malloc(token->length + 1);
+ copy = k5memdup0(token->value, token->length, &ret);
if (copy == NULL) {
status = GSS_S_FAILURE;
- *minor_status = ENOMEM;
+ *minor_status = ret;
goto cleanup;
}
- memcpy(copy, token->value, token->length);
- copy[token->length] = '\0';
v = k5_json_decode(copy);
if (v == NULL)
goto invalid;
stringrep = NULL;
- tmp = k5alloc(input_name_buffer->length + 1, &code);
+ tmp = k5memdup0(input_name_buffer->value, input_name_buffer->length,
+ &code);
if (tmp == NULL)
goto cleanup;
tmp2 = NULL;
- memcpy(tmp, input_name_buffer->value, input_name_buffer->length);
- tmp[input_name_buffer->length] = '\0';
-
/* Find the appropriate string rep to pass into parse_name. */
if ((input_name_type == GSS_C_NULL_OID) ||
g_OID_equal(input_name_type, gss_nt_krb5_name) ||
/* If a host was given, we have to use the canonicalized form of it (as
* given by krb5_sname_to_principal) for backward compatibility. */
const krb5_data *d = &name->princ->data[1];
- tmp = k5alloc(d->length + 1, &code);
+ tmp = k5memdup0(d->data, d->length, &code);
if (tmp == NULL)
return ENOMEM;
- memcpy(tmp, d->data, d->length);
- tmp[d->length] = '\0';
host = tmp;
} else /* No host was given; use an empty string. */
host = "";
ks_tuple = handle->params.keysalts;
}
/* Dup the requested or defaulted keysalt tuples. */
- new_ks_tuple = malloc(n_ks_tuple * sizeof(*new_ks_tuple));
- if (new_ks_tuple == NULL) {
- ret = ENOMEM;
+ new_ks_tuple = k5memdup(ks_tuple, n_ks_tuple * sizeof(*new_ks_tuple),
+ &ret);
+ if (new_ks_tuple == NULL)
goto cleanup;
- }
- memcpy(new_ks_tuple, ks_tuple, n_ks_tuple * sizeof(*new_ks_tuple));
new_n_ks_tuple = n_ks_tuple;
ret = 0;
goto cleanup;
if (retval)
goto clean_n_exit;
- key->contents = malloc(tmp_key.length);
- if (key->contents == NULL) {
- retval = ENOMEM;
+ key->contents = k5memdup(tmp_key.contents, tmp_key.length, &retval);
+ if (key->contents == NULL)
goto clean_n_exit;
- }
key->magic = tmp_key.magic;
key->enctype = tmp_key.enctype;
key->length = tmp_key.length;
- memcpy(key->contents, tmp_key.contents, tmp_key.length);
}
clean_n_exit:
* kt_ent will be free'd so need to allocate and copy key contents for
* output to caller.
*/
- if (!(key->contents = (krb5_octet *)malloc(key->length))) {
- retval = ENOMEM;
+ key->contents = k5memdup(kt_ent.key.contents, kt_ent.key.length,
+ &retval);
+ if (key->contents == NULL) {
krb5_kt_free_entry(context, &kt_ent);
goto errout;
}
- memcpy(key->contents, kt_ent.key.contents, kt_ent.key.length);
krb5_kt_free_entry(context, &kt_ent);
}
continue;
if (upd->kdb_deleted) {
- dbprincstr = k5alloc(upd->kdb_princ_name.utf8str_t_len + 1,
- &retval);
+ dbprincstr = k5memdup0(upd->kdb_princ_name.utf8str_t_val,
+ upd->kdb_princ_name.utf8str_t_len, &retval);
if (dbprincstr == NULL)
goto cleanup;
- memcpy(dbprincstr, (char *)upd->kdb_princ_name.utf8str_t_val,
- upd->kdb_princ_name.utf8str_t_len);
- dbprincstr[upd->kdb_princ_name.utf8str_t_len] = '\0';
retval = krb5_parse_name(context, dbprincstr, &dbprinc);
free(dbprincstr);
resid = name;
} else {
resid = name + pfxlen + 1;
-
- pfx = malloc (pfxlen+1);
- if (!pfx)
- return ENOMEM;
-
- memcpy (pfx, name, pfxlen);
- pfx[pfxlen] = '\0';
+ pfx = k5memdup0(name, pfxlen, &err);
+ if (pfx == NULL)
+ return err;
}
*cache = (krb5_ccache) 0;
ret_entry->key.enctype = ENCTYPE_DES_CBC_CRC;
ret_entry->key.magic = KV5M_KEYBLOCK;
ret_entry->key.length = sizeof(key);
- ret_entry->key.contents = malloc(sizeof(key));
- if (!ret_entry->key.contents) {
+ ret_entry->key.contents = k5memdup(key, sizeof(key), &kerror);
+ if (ret_entry->key.contents == NULL) {
krb5_free_principal(context, ret_entry->principal);
- return ENOMEM;
+ return kerror;
}
- memcpy(ret_entry->key.contents, key, sizeof(key));
return 0;
}
resid = name;
} else {
resid = name + pfxlen + 1;
-
- pfx = malloc (pfxlen+1);
- if (!pfx)
- return ENOMEM;
-
- memcpy (pfx, name, pfxlen);
- pfx[pfxlen] = '\0';
+ pfx = k5memdup0(name, pfxlen, &err);
+ if (pfx == NULL)
+ return err;
}
*ktid = (krb5_keytab) 0;
tempto->transited.tr_contents.data = 0;
} else {
tempto->transited.tr_contents.data =
- malloc(partfrom->transited.tr_contents.length);
+ k5memdup(partfrom->transited.tr_contents.data,
+ partfrom->transited.tr_contents.length, &retval);
if (!tempto->transited.tr_contents.data) {
krb5_free_principal(context, tempto->client);
krb5_free_keyblock(context, tempto->session);
free(tempto);
return ENOMEM;
}
- memcpy(tempto->transited.tr_contents.data,
- (char *)partfrom->transited.tr_contents.data,
- partfrom->transited.tr_contents.length);
}
retval = krb5_copy_addresses(context, partfrom->caddrs, &tempto->caddrs);
goto errout;
}
- rhost = malloc(server->data[1].length+1);
- if (!rhost) {
- retval = ENOMEM;
+ rhost = k5memdup0(server->data[1].data, server->data[1].length,
+ &retval);
+ if (rhost == NULL)
goto errout;
- }
free_rhost = 1;
- memcpy(rhost, server->data[1].data, server->data[1].length);
- rhost[server->data[1].length] = '\0';
}
retval = krb5_os_hostaddr(context, rhost, &addrs);
/* enctypes */
if (opte->flags & KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST) {
ctx->request->ktype =
- k5alloc((opte->etype_list_length * sizeof(krb5_enctype)),
- &code);
+ k5memdup(opte->etype_list,
+ opte->etype_list_length * sizeof(krb5_enctype), &code);
if (code != 0)
goto cleanup;
ctx->request->nktypes = opte->etype_list_length;
- memcpy(ctx->request->ktype, opte->etype_list,
- ctx->request->nktypes * sizeof(krb5_enctype));
} else if (krb5_get_default_in_tkt_ktypes(context,
&ctx->request->ktype) == 0) {
ctx->request->nktypes = k5_count_etypes(ctx->request->ktype);
if (ret != 0)
return ret;
- data->data = malloc(d.length);
+ data->data = k5memdup(d.data, d.length, &ret);
if (data->data == NULL)
- return ENOMEM;
-
+ return ret;
data->length = d.length;
- memcpy(data->data, d.data, d.length);
return 0;
}
if (pac == NULL)
return ENOMEM;
- pac->pac = (PACTYPE *)malloc(header_len);
+ pac->pac = k5memdup(src->pac, header_len, &code);
if (pac->pac == NULL) {
free(pac);
- return ENOMEM;
+ return code;
}
- memcpy(pac->pac, src->pac, header_len);
-
code = krb5int_copy_data_contents(context, &src->data, &pac->data);
if (code != 0) {
free(pac->pac);
return KRB5KRB_AP_ERR_INAPP_CKSUM;
pac_data.length = pac->data.length;
- pac_data.data = malloc(pac->data.length);
+ pac_data.data = k5memdup(pac->data.data, pac->data.length, &ret);
if (pac_data.data == NULL)
- return ENOMEM;
-
- memcpy(pac_data.data, pac->data.data, pac->data.length);
+ return ret;
/* Zero out both checksum buffers */
ret = k5_pac_zero_signature(context, pac, KRB5_PAC_SERVER_CHECKSUM,
if (ret != 0)
return ret;
- data->data = malloc(pac->data.length);
+ data->data = k5memdup(pac->data.data, pac->data.length, &ret);
if (data->data == NULL)
- return ENOMEM;
-
+ return ret;
data->length = pac->data.length;
- memcpy(data->data, pac->data.data, pac->data.length);
memset(pac->data.data, 0,
PACTYPE_LENGTH + (pac->pac->cBuffers * PAC_INFO_BUFFER_LENGTH));
if (pa == NULL)
return ret;
*pa = *cookie;
- pa->contents = k5alloc(cookie->length, &ret);
+ pa->contents = k5memdup(cookie->contents, cookie->length, &ret);
if (pa->contents == NULL)
goto error;
- memcpy(pa->contents, cookie->contents, cookie->length);
ret = grow_pa_list(out_pa_list, out_pa_list_size, &pa, 1);
if (ret)
goto error;
s4u_padata->magic = KV5M_PA_DATA;
s4u_padata->pa_type = KRB5_PADATA_S4U_X509_USER;
- s4u_padata->contents = malloc(userid->subject_cert.length);
+ s4u_padata->contents = k5memdup(userid->subject_cert.data,
+ userid->subject_cert.length, &code);
if (s4u_padata->contents == NULL) {
free(s4u_padata);
- return ENOMEM;
+ return code;
}
- memcpy(s4u_padata->contents, userid->subject_cert.data, userid->subject_cert.length);
s4u_padata->length = userid->subject_cert.length;
code = grow_pa_list(out_pa_list, out_pa_list_size, &s4u_padata, 1);
if (padata[0] == NULL)
goto cleanup;
padata[0]->pa_type = KRB5_PADATA_AP_REQ;
- padata[0]->contents = k5alloc(ap_req_asn1->length, &ret);
+ padata[0]->contents = k5memdup(ap_req_asn1->data, ap_req_asn1->length,
+ &ret);
if (padata[0] == NULL)
goto cleanup;
- memcpy(padata[0]->contents, ap_req_asn1->data, ap_req_asn1->length);
padata[0]->length = ap_req_asn1->length;
/* Append copies of any other supplied padata. */
goto cleanup;
pa->pa_type = in_padata[i]->pa_type;
pa->length = in_padata[i]->length;
- pa->contents = k5alloc(in_padata[i]->length, &ret);
+ pa->contents = k5memdup(in_padata[i]->contents, in_padata[i]->length,
+ &ret);
if (pa->contents == NULL)
goto cleanup;
- memcpy(pa->contents, in_padata[i]->contents, in_padata[i]->length);
padata[i + 1] = pa;
}
req.padata = padata;
*vals = NULL;
- clientz = calloc(client->length + 1, 1);
- if (clientz == NULL) {
- retval = ENOMEM;
+ clientz = k5memdup0(client->data, client->length, &retval);
+ if (clientz == NULL)
goto error;
- }
- memcpy(clientz, client->data, client->length);
- serverz = calloc(server->length + 1, 1);
- if (serverz == NULL) {
- retval = ENOMEM;
+ serverz = k5memdup0(server->data, server->length, &retval);
+ if (serverz == NULL)
goto error;
- }
- memcpy(serverz, server->data, server->length);
key[0] = "capaths";
key[1] = clientz;
krb5_error_code kret;
char *in = NULL, *out = NULL, *rule = NULL, *repl = NULL;
char *cp, *ep, *tp;
- size_t rule_size, repl_size;
int doglobal;
*result = NULL;
goto cleanup;
}
- /* Figure out sizes of strings and allocate them */
- rule_size = (size_t) (ep - &cp[2]);
- repl_size = (size_t) (tp - &ep[1]);
- rule = malloc(rule_size + 1);
- if (!rule) {
- kret = ENOMEM;
+ /* Copy the rule and replacement strings. */
+ rule = k5memdup0(&cp[2], ep - &cp[2], &kret);
+ if (rule == NULL)
goto cleanup;
- }
- repl = malloc(repl_size + 1);
- if (!repl) {
- kret = ENOMEM;
+ repl = k5memdup0(&ep[1], tp - &ep[1], &kret);
+ if (repl == NULL)
goto cleanup;
- }
-
- /* Copy the strings */
- memcpy(rule, &cp[2], rule_size);
- memcpy(repl, &ep[1], repl_size);
- rule[rule_size] = repl[repl_size] = '\0';
/* Check for trailing "g" */
doglobal = (tp[1] == 'g') ? 1 : 0;
local_kaddr.magic = addrs[0]->magic;
local_kaddr.addrtype = addrs[0]->addrtype;
local_kaddr.length = addrs[0]->length;
- local_kaddr.contents = malloc(addrs[0]->length);
- if (local_kaddr.contents == NULL && addrs[0]->length != 0) {
- code = ENOMEM;
- krb5_free_addresses(ctx->context, addrs);
- goto cleanup;
- }
- if (addrs[0]->length)
- memcpy(local_kaddr.contents, addrs[0]->contents, addrs[0]->length);
-
+ local_kaddr.contents = k5memdup(addrs[0]->contents, addrs[0]->length,
+ &code);
krb5_free_addresses(ctx->context, addrs);
+ if (local_kaddr.contents == NULL)
+ goto cleanup;
}
goto cleanup;
}
for (i = 0; i < count; i++) {
- unsigned int len = strlen (values[i]) + 1;
- rethosts[i] = malloc(len);
- if (!rethosts[i]) {
- retval = ENOMEM;
+ rethosts[i] = k5memdup0(values[i], strlen(values[i]), &retval);
+ if (rethosts[i] == NULL)
goto cleanup;
- }
- memcpy (rethosts[i], values[i], len);
}
rethosts[count] = 0;
cleanup:
addrs[i]->magic = KV5M_ADDRESS;
addrs[i]->addrtype = atype;
addrs[i]->length = addrlen;
- addrs[i]->contents = malloc(addrs[i]->length);
- if (!addrs[i]->contents) {
- retval = ENOMEM;
+ addrs[i]->contents = k5memdup(ptr, addrlen, &retval);
+ if (addrs[i]->contents == NULL)
goto errout;
- }
- memcpy (addrs[i]->contents, ptr, addrs[i]->length);
i++;
}
krb5int_free_plugin_dir_data(ptrs);
return ENOMEM;
}
- realmz = malloc(realm->length + 1);
+ realmz = k5memdup0(realm->data, realm->length, &code);
if (realmz == NULL) {
krb5int_free_plugin_dir_data(ptrs);
- return ENOMEM;
+ return code;
}
- memcpy(realmz, realm->data, realm->length);
- realmz[realm->length] = '\0';
for (i = 0; ptrs[i]; i++) {
void *blob;
end = strchr(str, ' ');
if (!end)
return 0;
- msghash = malloc(end - str + 1);
+ msghash = k5memdup0(str, end - str, &retval);
if (!msghash)
return KRB5_RC_MALLOC;
- memcpy(msghash, str, end - str);
- msghash[end - str] = '\0';
str = end + 1;
/* Parse out the client and server. */
if (i == len) {
newdata->length = len;
- newdata->data = malloc(newdata->length + 1);
- if (newdata->data == NULL) {
- retval = ENOMEM;
+ newdata->data = k5memdup0(s, len, &retval);
+ if (newdata->data == NULL)
goto cleanup;
- }
- memcpy(newdata->data, s, len);
- newdata->data[len] = '\0';
*newdataptr = newdata;
return 0;
}
entry = k5alloc(sizeof(*entry), &ret);
if (entry == NULL)
goto error;
- aligned_data = k5alloc(dbdata.size, &ret);
+ aligned_data = k5memdup(dbdata.data, dbdata.size, &ret);
if (aligned_data == NULL)
goto error;
- memcpy(aligned_data, dbdata.data, dbdata.size);
xdrmem_create(&xdrs, aligned_data, dbdata.size, XDR_DECODE);
if (!xdr_osa_policy_ent_rec(&xdrs, entry)) {
ret = OSA_ADB_FAILURE;
goto error;
}
- if(!(aligned_data = (char *) malloc(dbdata.size))) {
- ret = ENOMEM;
+ aligned_data = k5memdup(dbdata.data, dbdata.size, &ret);
+ if (aligned_data == NULL)
goto error;
- }
- memcpy(aligned_data, dbdata.data, dbdata.size);
memset(entry, 0, sizeof(osa_policy_ent_rec));
xdrmem_create(&xdrs, aligned_data, dbdata.size, XDR_DECODE);
/* Check for extra data */
if (entry->len > KRB5_KDB_V1_BASE_LENGTH) {
entry->e_length = entry->len - KRB5_KDB_V1_BASE_LENGTH;
- entry->e_data = k5alloc(entry->e_length, &retval);
+ entry->e_data = k5memdup(nextloc, entry->e_length, &retval);
if (entry->e_data == NULL)
goto error_out;
- memcpy(entry->e_data, nextloc, entry->e_length);
nextloc += entry->e_length;
}
retval = KRB5_KDB_TRUNCATED_RECORD;
goto error_out;
}
- if (((*tl_data)->tl_data_contents = (krb5_octet *)
- malloc((*tl_data)->tl_data_length)) == NULL) {
- retval = ENOMEM;
+ (*tl_data)->tl_data_contents =
+ k5memdup(nextloc, (*tl_data)->tl_data_length, &retval);
+ if ((*tl_data)->tl_data_contents == NULL)
goto error_out;
- }
- memcpy((*tl_data)->tl_data_contents,nextloc,(*tl_data)->tl_data_length);
nextloc += (*tl_data)->tl_data_length;
tl_data = &((*tl_data)->tl_data_next);
}
goto error_out;
}
if (key_data->key_data_length[j]) {
- if ((key_data->key_data_contents[j] = (krb5_octet *)
- malloc(key_data->key_data_length[j])) == NULL) {
- retval = ENOMEM;
+ key_data->key_data_contents[j] =
+ k5memdup(nextloc, key_data->key_data_length[j],
+ &retval);
+ if (key_data->key_data_contents[j] == NULL)
goto error_out;
- }
- memcpy(key_data->key_data_contents[j], nextloc,
- key_data->key_data_length[j]);
nextloc += key_data->key_data_length[j];
}
}
UNSTORE16_INT(curr, sublen);
/* forward by 2 bytes */
curr += 2;
- DN = malloc (sublen + 1);
+ DN = k5memdup0(curr, sublen, &st);
if (DN == NULL)
- return ENOMEM;
- memcpy(DN, curr, sublen);
- DN[sublen] = 0;
+ return st;
*data = DN;
curr += sublen;
st = 0;
UNSTORE16_INT(curr, sublen);
/* forward by 2 bytes */
curr += 2;
- DNarr[i] = malloc (sublen + 1);
+ DNarr[i] = k5memdup0(curr, sublen, &st);
if (DNarr[i] == NULL)
- return ENOMEM;
- memcpy(DNarr[i], curr, sublen);
- DNarr[i][sublen] = 0;
+ return st;
++i;
curr += sublen;
*data = DNarr;
return ENOMEM;
(*mods)[i]->mod_bvalues[j]->bv_len = ber_values[j]->bv_len;
- (*mods)[i]->mod_bvalues[j]->bv_val = malloc((*mods)[i]->mod_bvalues[j]->bv_len);
+ (*mods)[i]->mod_bvalues[j]->bv_val =
+ k5memdup(ber_values[j]->bv_val, ber_values[j]->bv_len, &st);
if ((*mods)[i]->mod_bvalues[j]->bv_val == NULL)
return ENOMEM;
-
- memcpy((*mods)[i]->mod_bvalues[j]->bv_val, ber_values[j]->bv_val,
- ber_values[j]->bv_len);
}
(*mods)[i]->mod_bvalues[j] = NULL;
return 0;
dptr)) != 0)
goto cleanup;
} else {
- *dptr = calloc (1, arg_val_len);
- if (*dptr == NULL) {
- st = ENOMEM;
+ *dptr = k5memdup(arg_val, arg_val_len, &st);
+ if (*dptr == NULL)
goto cleanup;
- }
- memcpy(*dptr, arg_val, arg_val_len);
}
}
}
tmp_oid = k5alloc(sizeof(krb5_data), &retval);
if (retval)
goto cleanup;
- tmp_oid->data = k5alloc(supp_oid->length, &retval);
+ tmp_oid->data = k5memdup(supp_oid->data, supp_oid->length,
+ &retval);
if (retval)
goto cleanup;
tmp_oid->length = supp_oid->length;
- memcpy(tmp_oid->data, supp_oid->data, tmp_oid->length);
*alg_oid = tmp_oid;
/* don't free the OID in clean-up if we are returning it */
tmp_oid = NULL;