} else
s = NULL;
- ret->length = (int)len;
- OPENSSL_free(ret->data);
- ret->data = s;
+ ASN1_STRING_set0(ret, s, (int)len);
ret->type = V_ASN1_BIT_STRING;
if (a != NULL)
(*a) = ret;
p += len;
}
- OPENSSL_free(ret->data);
- ret->data = s;
- ret->length = (int)len;
+ ASN1_STRING_set0(ret, s, (int)len);
if (a != NULL)
(*a) = ret;
*pp = p;
if (*out) {
free_out = 0;
dest = *out;
- OPENSSL_free(dest->data);
- dest->data = NULL;
- dest->length = 0;
+ ASN1_STRING_set0(dest, NULL, 0);
dest->type = str_type;
} else {
free_out = 1;
ERR_raise(ERR_LIB_ASN1, ERR_R_EVP_LIB);
goto err;
}
- OPENSSL_free(signature->data);
- signature->data = buf_out;
+ ASN1_STRING_set0(signature, buf_out, outl);
buf_out = NULL;
- signature->length = outl;
/*
* In the interests of compatibility, I'll make sure that the bit string
* has a 'not-used bits' value of 0
ERR_raise(ERR_LIB_ASN1, ERR_R_EVP_LIB);
goto err;
}
- OPENSSL_free(signature->data);
- signature->data = buf_out;
+ ASN1_STRING_set0(signature, buf_out, outl);
buf_out = NULL;
- signature->length = outl;
/*
* In the interests of compatibility, I'll make sure that the bit string
* has a 'not-used bits' value of 0
{
ASN1_STRING *octmp;
- if (oct == NULL || *oct == NULL) {
+ if (oct == NULL || *oct == NULL) {
if ((octmp = ASN1_STRING_new()) == NULL) {
ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE);
return NULL;
octmp = *oct;
}
- OPENSSL_free(octmp->data);
- octmp->data = NULL;
+ ASN1_STRING_set0(octmp, NULL, 0);
if ((octmp->length = ASN1_item_i2d(obj, &octmp->data, it)) == 0) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_ENCODE_ERROR);
}
/* If we've already allocated a buffer use it */
if (*free_cont) {
- OPENSSL_free(stmp->data);
- stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */
- stmp->length = len;
+ ASN1_STRING_set0(stmp, (unsigned char *)cont /* UGLY CAST! */, len);
*free_cont = 0;
} else {
if (!ASN1_STRING_set(stmp, cont, len)) {
void X509_PUBKEY_set0_public_key(X509_PUBKEY *pub,
unsigned char *penc, int penclen)
{
- OPENSSL_free(pub->public_key->data);
- pub->public_key->data = penc;
- pub->public_key->length = penclen;
+ ASN1_STRING_set0(pub->public_key, penc, penclen);
/* Set number of unused bits to zero */
pub->public_key->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
pub->public_key->flags |= ASN1_STRING_FLAG_BITS_LEFT;