#else
ec = 0;
#endif
- plain.length = message->length + 16 + ec;
- plain.data = malloc(message->length + 16 + ec);
- if (plain.data == NULL)
- return ENOMEM;
+ err = alloc_data(&plain, message->length + 16 + ec);
+ if (err)
+ return err;
/* Get size of ciphertext. */
bufsize = 16 + krb5_encrypt_size (plain.length, key->keyblock.enctype);
tok_id = KG2_TOK_WRAP_MSG;
wrap_with_checksum:
- plain.length = message->length + 16;
- plain.data = malloc(message->length + 16);
- if (plain.data == NULL)
- return ENOMEM;
+ err = alloc_data(&plain, message->length + 16);
+ if (err)
+ return err;
err = krb5_c_checksum_length(context, cksumtype, &cksumsize);
if (err)
Rotate the first two. */
store_16_be(0, ptr+4);
store_16_be(0, ptr+6);
- plain.length = bodysize-ec;
- plain.data = (char *)ptr;
+ plain = make_data(ptr, bodysize - ec);
if (!gss_krb5int_rotate_left(ptr, bodysize-ec, 16))
goto no_mem;
sum.length = ec;
krb5_int32 nelem;
register int i;
- if (pr == 0) {
- ret->length = 0;
- ret->data = 0;
+ *ret = empty_data();
+ if (pr == NULL)
return 0;
- }
nelem = krb5_princ_size(context, pr);
for (i = 0; i < (int) nelem; i++)
size += krb5_princ_component(context, pr, i)->length;
- ret->length = size;
- if (!(ret->data = malloc (size)))
+ if (alloc_data(ret, size))
return ENOMEM;
if (use_realm) {
char *buf = NULL;
int fd = *( (int *) fdp);
- inbuf->data = NULL;
- inbuf->length = 0;
+ *inbuf = empty_data();
if ((len2 = krb5_net_read(context, fd, (char *)&len, 4)) != 4)
return((len2 < 0) ? errno : ECONNABORTED);
if ((len & VALID_UINT_BITS) != (krb5_ui_4) len) /* Overflow size_t??? */
return ENOMEM;
- inbuf->length = ilen = (int) len;
+ ilen = (int)len;
if (ilen) {
/*
* We may want to include a sanity check here someday....
*/
- if (!(buf = malloc(inbuf->length))) {
+ if (!(buf = malloc(ilen))) {
return(ENOMEM);
}
if ((len2 = krb5_net_read(context, fd, buf, ilen)) != ilen) {
return((len2 < 0) ? errno : ECONNABORTED);
}
}
- inbuf->data = buf;
+ *inbuf = make_data(buf, ilen);
return(0);
}