if (len-- > 1) /* using one because of the bits left byte */
{
- s = (unsigned char *)malloc((int)len);
+ s = malloc((int)len);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if ((a->length < (w + 1)) || (a->data == NULL)) {
if (!value)
return(1); /* Don't need to set */
- if (a->data == NULL)
- c = (unsigned char *)malloc(w + 1);
- else
- c = (unsigned char *)OPENSSL_realloc_clean(a->data,
- a->length, w + 1);
+ c = OPENSSL_realloc_clean(a->data, a->length, w + 1);
if (c == NULL) {
ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE);
return 0;
ret = (*a);
if (len != 0) {
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if ((ret->length < len) || (ret->data == NULL)) {
if (ret->data != NULL)
free(ret->data);
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc(len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
free(a->data);
- if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL)
- memset((char *)a->data, 0, sizeof(long) + 1);
+ a->data = calloc(1, sizeof(long) + 1);
}
if (a->data == NULL) {
ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE);
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
- b = (char *)malloc(n);
+ b = malloc(n);
if (b == NULL) {
ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
return (0);
/* We must malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
/* We must malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
free(a->data);
- if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL)
- memset((char *)a->data, 0, sizeof(long) + 1);
+ a->data = calloc(1, sizeof(long) + 1);
}
if (a->data == NULL) {
ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE);
ret->length = 0;
if (data != NULL)
free(data);
- data = (unsigned char *)malloc(len ? (int)len : 1);
+ data = malloc(len ? (int)len : 1);
if (data == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
{
ASN1_OBJECT *ret;
- ret = (ASN1_OBJECT *)malloc(sizeof(ASN1_OBJECT));
+ ret = malloc(sizeof(ASN1_OBJECT));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
{
EVP_PKEY_ASN1_METHOD *ameth;
- ameth = malloc(sizeof(EVP_PKEY_ASN1_METHOD));
+ ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD));
if (!ameth)
return NULL;
- memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD));
-
ameth->pkey_id = id;
ameth->pkey_base_id = id;
ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
{
ASN1_STRING *ret;
- ret = (ASN1_STRING *)malloc(sizeof(ASN1_STRING));
+ ret = malloc(sizeof(ASN1_STRING));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}
}
} else tmpval = NULL;
- mhdr = (MIME_HEADER *)malloc(sizeof(MIME_HEADER));
+ mhdr = malloc(sizeof(MIME_HEADER));
if (!mhdr) {
OPENSSL_free(tmpname);
return NULL;
} else
tmpval = NULL;
/* Parameter values are case sensitive so leave as is */
- mparam = (MIME_PARAM *) malloc(sizeof(MIME_PARAM));
+ mparam = malloc(sizeof(MIME_PARAM));
if (!mparam)
return 0;
mparam->param_name = tmpname;
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = (unsigned char *)malloc(
- (unsigned int)num + i * 2);
- else
- sp = (unsigned char *)realloc(s,
- (unsigned int)num + i * 2);
+ sp = realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,
ERR_R_MALLOC_FAILURE);
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = (unsigned char *)malloc(
- (unsigned int)num + i * 2);
- else
- sp = OPENSSL_realloc_clean(s, slen,
- num + i * 2);
+ sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER,
ERR_R_MALLOC_FAILURE);
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = (unsigned char *)malloc(
- (unsigned int)num + i * 2);
- else
- sp = (unsigned char *)realloc(s,
- (unsigned int)num + i * 2);
+ sp = realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING,
ERR_R_MALLOC_FAILURE);
}
/* Since its RC4 encrypted length is actual length */
- if ((zz = (unsigned char *)malloc(rsalen)) == NULL) {
+ if ((zz = malloc(rsalen)) == NULL) {
ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE);
goto err;
}
if (BIO_printf(bp, " Subject OCSP hash: ") <= 0)
goto err;
derlen = i2d_X509_NAME(x->cert_info->subject, NULL);
- if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL)
+ if ((der = dertmp = malloc(derlen)) == NULL)
goto err;
i2d_X509_NAME(x->cert_info->subject, &dertmp);
}
}
if (!combine) {
- *pval = malloc(it->size);
+ *pval = calloc(1, it->size);
if (!*pval)
goto memerr;
- memset(*pval, 0, it->size);
}
asn1_set_choice_selector(pval, -1, it);
if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
}
}
if (!combine) {
- *pval = malloc(it->size);
+ *pval = calloc(1, it->size);
if (!*pval)
goto memerr;
- memset(*pval, 0, it->size);
asn1_do_lock(pval, 0, it);
asn1_enc_init(pval, it);
}
{
X509_INFO *ret = NULL;
- ret = (X509_INFO *)malloc(sizeof(X509_INFO));
+ ret = malloc(sizeof(X509_INFO));
if (ret == NULL) {
ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
if (len-- > 1) /* using one because of the bits left byte */
{
- s = (unsigned char *)malloc((int)len);
+ s = malloc((int)len);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if ((a->length < (w + 1)) || (a->data == NULL)) {
if (!value)
return(1); /* Don't need to set */
- if (a->data == NULL)
- c = (unsigned char *)malloc(w + 1);
- else
- c = (unsigned char *)OPENSSL_realloc_clean(a->data,
- a->length, w + 1);
+ c = OPENSSL_realloc_clean(a->data, a->length, w + 1);
if (c == NULL) {
ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE);
return 0;
ret = (*a);
if (len != 0) {
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if ((ret->length < len) || (ret->data == NULL)) {
if (ret->data != NULL)
free(ret->data);
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc(len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
free(a->data);
- if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL)
- memset((char *)a->data, 0, sizeof(long) + 1);
+ a->data = calloc(1, sizeof(long) + 1);
}
if (a->data == NULL) {
ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE);
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
- b = (char *)malloc(n);
+ b = malloc(n);
if (b == NULL) {
ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
return (0);
/* We must malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
/* We must malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */
- s = (unsigned char *)malloc((int)len + 1);
+ s = malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
free(a->data);
- if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL)
- memset((char *)a->data, 0, sizeof(long) + 1);
+ a->data = calloc(1, sizeof(long) + 1);
}
if (a->data == NULL) {
ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE);
ret->length = 0;
if (data != NULL)
free(data);
- data = (unsigned char *)malloc(len ? (int)len : 1);
+ data = malloc(len ? (int)len : 1);
if (data == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
{
ASN1_OBJECT *ret;
- ret = (ASN1_OBJECT *)malloc(sizeof(ASN1_OBJECT));
+ ret = malloc(sizeof(ASN1_OBJECT));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
{
EVP_PKEY_ASN1_METHOD *ameth;
- ameth = malloc(sizeof(EVP_PKEY_ASN1_METHOD));
+ ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD));
if (!ameth)
return NULL;
- memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD));
-
ameth->pkey_id = id;
ameth->pkey_base_id = id;
ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
{
ASN1_STRING *ret;
- ret = (ASN1_STRING *)malloc(sizeof(ASN1_STRING));
+ ret = malloc(sizeof(ASN1_STRING));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}
}
} else tmpval = NULL;
- mhdr = (MIME_HEADER *)malloc(sizeof(MIME_HEADER));
+ mhdr = malloc(sizeof(MIME_HEADER));
if (!mhdr) {
OPENSSL_free(tmpname);
return NULL;
} else
tmpval = NULL;
/* Parameter values are case sensitive so leave as is */
- mparam = (MIME_PARAM *) malloc(sizeof(MIME_PARAM));
+ mparam = malloc(sizeof(MIME_PARAM));
if (!mparam)
return 0;
mparam->param_name = tmpname;
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = (unsigned char *)malloc(
- (unsigned int)num + i * 2);
- else
- sp = (unsigned char *)realloc(s,
- (unsigned int)num + i * 2);
+ sp = realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,
ERR_R_MALLOC_FAILURE);
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = (unsigned char *)malloc(
- (unsigned int)num + i * 2);
- else
- sp = OPENSSL_realloc_clean(s, slen,
- num + i * 2);
+ sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER,
ERR_R_MALLOC_FAILURE);
}
i /= 2;
if (num + i > slen) {
- if (s == NULL)
- sp = (unsigned char *)malloc(
- (unsigned int)num + i * 2);
- else
- sp = (unsigned char *)realloc(s,
- (unsigned int)num + i * 2);
+ sp = realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING,
ERR_R_MALLOC_FAILURE);
}
/* Since its RC4 encrypted length is actual length */
- if ((zz = (unsigned char *)malloc(rsalen)) == NULL) {
+ if ((zz = malloc(rsalen)) == NULL) {
ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE);
goto err;
}
if (BIO_printf(bp, " Subject OCSP hash: ") <= 0)
goto err;
derlen = i2d_X509_NAME(x->cert_info->subject, NULL);
- if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL)
+ if ((der = dertmp = malloc(derlen)) == NULL)
goto err;
i2d_X509_NAME(x->cert_info->subject, &dertmp);
}
}
if (!combine) {
- *pval = malloc(it->size);
+ *pval = calloc(1, it->size);
if (!*pval)
goto memerr;
- memset(*pval, 0, it->size);
}
asn1_set_choice_selector(pval, -1, it);
if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
}
}
if (!combine) {
- *pval = malloc(it->size);
+ *pval = calloc(1, it->size);
if (!*pval)
goto memerr;
- memset(*pval, 0, it->size);
asn1_do_lock(pval, 0, it);
asn1_enc_init(pval, it);
}
{
X509_INFO *ret = NULL;
- ret = (X509_INFO *)malloc(sizeof(X509_INFO));
+ ret = malloc(sizeof(X509_INFO));
if (ret == NULL) {
ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);