summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-04-28 15:28:14 -0400
committerRich Salz <rsalz@openssl.org>2015-04-28 15:28:14 -0400
commitb196e7d936fb377d9c5b305748ac25ff0e53ef6d (patch)
treec855f0808899e5e7ef3a704c35f464ca36014964 /crypto
parent3e47caff4830d2a117eda15b57a5feab89b846ae (diff)
remove malloc casts
Following ANSI C rules, remove the casts from calls to OPENSSL_malloc and OPENSSL_realloc. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/a_bitstr.c7
-rw-r--r--crypto/asn1/a_digest.c2
-rw-r--r--crypto/asn1/a_enum.c3
-rw-r--r--crypto/asn1/a_i2d_fp.c2
-rw-r--r--crypto/asn1/a_int.c7
-rw-r--r--crypto/asn1/a_object.c4
-rw-r--r--crypto/asn1/a_sign.c4
-rw-r--r--crypto/asn1/asn1_lib.c2
-rw-r--r--crypto/asn1/asn_mime.c4
-rw-r--r--crypto/asn1/f_enum.c7
-rw-r--r--crypto/asn1/f_int.c3
-rw-r--r--crypto/asn1/f_string.c7
-rw-r--r--crypto/asn1/n_pkey.c2
-rw-r--r--crypto/asn1/t_x509.c2
-rw-r--r--crypto/asn1/x_info.c2
-rw-r--r--crypto/bio/bf_buff.c10
-rw-r--r--crypto/bio/bf_lbuf.c6
-rw-r--r--crypto/bio/bf_nbio.c2
-rw-r--r--crypto/bio/bio_lib.c2
-rw-r--r--crypto/bio/bss_acpt.c2
-rw-r--r--crypto/bio/bss_conn.c2
-rw-r--r--crypto/bio/bss_log.c2
-rw-r--r--crypto/bn/bn_blind.c2
-rw-r--r--crypto/bn/bn_exp.c3
-rw-r--r--crypto/bn/bn_gf2m.c10
-rw-r--r--crypto/bn/bn_lib.c6
-rw-r--r--crypto/bn/bn_mont.c2
-rw-r--r--crypto/bn/bn_print.c7
-rw-r--r--crypto/bn/bn_rand.c2
-rw-r--r--crypto/bn/bn_recp.c2
-rw-r--r--crypto/comp/c_zlib.c3
-rw-r--r--crypto/comp/comp_lib.c2
-rw-r--r--crypto/conf/conf_def.c6
-rw-r--r--crypto/dh/dh_lib.c3
-rw-r--r--crypto/dsa/dsa_ameth.c2
-rw-r--r--crypto/dsa/dsa_lib.c2
-rw-r--r--crypto/dso/dso_lib.c5
-rw-r--r--crypto/dso/dso_win32.c2
-rw-r--r--crypto/ec/ec_ameth.c2
-rw-r--r--crypto/ec/ec_key.c2
-rw-r--r--crypto/ec/ec_mult.c2
-rw-r--r--crypto/ec/ec_print.c2
-rw-r--r--crypto/ec/ecp_nistp224.c2
-rw-r--r--crypto/ec/ecp_nistp256.c2
-rw-r--r--crypto/ec/ecp_nistp521.c2
-rw-r--r--crypto/ec/ecp_nistz256.c2
-rw-r--r--crypto/ecdh/ech_lib.c2
-rw-r--r--crypto/ecdsa/ecs_lib.c2
-rw-r--r--crypto/engine/eng_cryptodev.c2
-rw-r--r--crypto/engine/eng_lib.c2
-rw-r--r--crypto/err/err.c2
-rw-r--r--crypto/evp/bio_b64.c2
-rw-r--r--crypto/evp/bio_enc.c2
-rw-r--r--crypto/evp/bio_ok.c2
-rw-r--r--crypto/evp/evp_pbe.c2
-rw-r--r--crypto/evp/p_lib.c2
-rw-r--r--crypto/evp/p_open.c2
-rw-r--r--crypto/ex_data.c3
-rw-r--r--crypto/lhash/lhash.c15
-rw-r--r--crypto/lock.c2
-rw-r--r--crypto/mem.c2
-rw-r--r--crypto/mem_dbg.c4
-rw-r--r--crypto/modes/gcm128.c2
-rw-r--r--crypto/modes/ocb128.c2
-rw-r--r--crypto/objects/o_names.c2
-rw-r--r--crypto/objects/obj_dat.c14
-rw-r--r--crypto/pem/pem_lib.c2
-rw-r--r--crypto/pem/pem_seal.c4
-rw-r--r--crypto/pem/pem_sign.c2
-rw-r--r--crypto/pqueue/pqueue.c4
-rw-r--r--crypto/rsa/rsa_ameth.c2
-rw-r--r--crypto/rsa/rsa_lib.c2
-rw-r--r--crypto/rsa/rsa_saos.c4
-rw-r--r--crypto/rsa/rsa_sign.c4
-rw-r--r--crypto/srp/srp_vfy.c7
-rw-r--r--crypto/stack/stack.c5
-rw-r--r--crypto/store/str_lib.c4
-rw-r--r--crypto/store/str_mem.c3
-rw-r--r--crypto/store/str_meth.c3
-rw-r--r--crypto/ts/ts_rsp_sign.c4
-rw-r--r--crypto/ts/ts_verify_ctx.c4
-rw-r--r--crypto/ui/ui_lib.c9
-rw-r--r--crypto/x509/by_dir.c2
-rw-r--r--crypto/x509/x509_lu.c8
-rw-r--r--crypto/x509/x509_req.c2
-rw-r--r--crypto/x509/x509_vfy.c3
-rw-r--r--crypto/x509v3/v3_lib.c4
-rw-r--r--crypto/x509v3/v3_utl.c2
88 files changed, 143 insertions, 168 deletions
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c
index 24cdb0f66a..8a9e17cb27 100644
--- a/crypto/asn1/a_bitstr.c
+++ b/crypto/asn1/a_bitstr.c
@@ -156,7 +156,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | i); /* set */
if (len-- > 1) { /* using one because of the bits left byte */
- s = (unsigned char *)OPENSSL_malloc((int)len);
+ s = OPENSSL_malloc((int)len);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
@@ -206,10 +206,9 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
if (!value)
return (1); /* Don't need to set */
if (a->data == NULL)
- c = (unsigned char *)OPENSSL_malloc(w + 1);
+ c = OPENSSL_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;
diff --git a/crypto/asn1/a_digest.c b/crypto/asn1/a_digest.c
index 7cbc4751cd..8fac13b89e 100644
--- a/crypto/asn1/a_digest.c
+++ b/crypto/asn1/a_digest.c
@@ -79,7 +79,7 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
unsigned char *str, *p;
i = i2d(data, NULL);
- if ((str = (unsigned char *)OPENSSL_malloc(i)) == NULL) {
+ if ((str = OPENSSL_malloc(i)) == NULL) {
ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_MALLOC_FAILURE);
return (0);
}
diff --git a/crypto/asn1/a_enum.c b/crypto/asn1/a_enum.c
index 00312b072d..54d6542cbe 100644
--- a/crypto/asn1/a_enum.c
+++ b/crypto/asn1/a_enum.c
@@ -77,8 +77,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
OPENSSL_free(a->data);
- if ((a->data =
- (unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL)
+ if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL)
memset((char *)a->data, 0, sizeof(long) + 1);
}
if (a->data == NULL) {
diff --git a/crypto/asn1/a_i2d_fp.c b/crypto/asn1/a_i2d_fp.c
index 746e34a856..e0f236e640 100644
--- a/crypto/asn1/a_i2d_fp.c
+++ b/crypto/asn1/a_i2d_fp.c
@@ -87,7 +87,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
- b = (char *)OPENSSL_malloc(n);
+ b = OPENSSL_malloc(n);
if (b == NULL) {
ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
return (0);
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c
index 3920d5ce96..b5246a65c3 100644
--- a/crypto/asn1/a_int.c
+++ b/crypto/asn1/a_int.c
@@ -206,7 +206,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies
* a missing NULL parameter.
*/
- s = (unsigned char *)OPENSSL_malloc((int)len + 1);
+ s = OPENSSL_malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
@@ -312,7 +312,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies
* a missing NULL parameter.
*/
- s = (unsigned char *)OPENSSL_malloc((int)len + 1);
+ s = OPENSSL_malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
@@ -351,8 +351,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
OPENSSL_free(a->data);
- if ((a->data =
- (unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL)
+ if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL)
memset((char *)a->data, 0, sizeof(long) + 1);
}
if (a->data == NULL) {
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c
index 845413cffa..166eb65a48 100644
--- a/crypto/asn1/a_object.c
+++ b/crypto/asn1/a_object.c
@@ -317,7 +317,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
ret->length = 0;
if (data != NULL)
OPENSSL_free(data);
- data = (unsigned char *)OPENSSL_malloc(length);
+ data = OPENSSL_malloc(length);
if (data == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
@@ -348,7 +348,7 @@ ASN1_OBJECT *ASN1_OBJECT_new(void)
{
ASN1_OBJECT *ret;
- ret = (ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT));
+ ret = OPENSSL_malloc(sizeof(ASN1_OBJECT));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
diff --git a/crypto/asn1/a_sign.c b/crypto/asn1/a_sign.c
index 9fe6665fbc..21cbe0c347 100644
--- a/crypto/asn1/a_sign.c
+++ b/crypto/asn1/a_sign.c
@@ -171,9 +171,9 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
}
}
inl = i2d(data, NULL);
- buf_in = (unsigned char *)OPENSSL_malloc((unsigned int)inl);
+ buf_in = OPENSSL_malloc((unsigned int)inl);
outll = outl = EVP_PKEY_size(pkey);
- buf_out = (unsigned char *)OPENSSL_malloc((unsigned int)outl);
+ buf_out = OPENSSL_malloc((unsigned int)outl);
if ((buf_in == NULL) || (buf_out == NULL)) {
outl = 0;
ASN1err(ASN1_F_ASN1_SIGN, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index b29e636358..97f1d23da8 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -354,7 +354,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
{
ASN1_STRING *ret;
- ret = (ASN1_STRING *)OPENSSL_malloc(sizeof(ASN1_STRING));
+ ret = OPENSSL_malloc(sizeof(ASN1_STRING));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c
index e810345579..9b397aeaa0 100644
--- a/crypto/asn1/asn_mime.c
+++ b/crypto/asn1/asn_mime.c
@@ -844,7 +844,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
}
}
}
- mhdr = (MIME_HEADER *)OPENSSL_malloc(sizeof(MIME_HEADER));
+ mhdr = OPENSSL_malloc(sizeof(MIME_HEADER));
if (!mhdr)
goto err;
mhdr->name = tmpname;
@@ -886,7 +886,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
goto err;
}
/* Parameter values are case sensitive so leave as is */
- mparam = (MIME_PARAM *)OPENSSL_malloc(sizeof(MIME_PARAM));
+ mparam = OPENSSL_malloc(sizeof(MIME_PARAM));
if (!mparam)
goto err;
mparam->param_name = tmpname;
diff --git a/crypto/asn1/f_enum.c b/crypto/asn1/f_enum.c
index 591c3b5781..c623cdc784 100644
--- a/crypto/asn1/f_enum.c
+++ b/crypto/asn1/f_enum.c
@@ -152,12 +152,9 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
i /= 2;
if (num + i > slen) {
if (s == NULL)
- sp = (unsigned char *)OPENSSL_malloc((unsigned int)num +
- i * 2);
+ sp = OPENSSL_malloc((unsigned int)num + i * 2);
else
- sp = (unsigned char *)OPENSSL_realloc(s,
- (unsigned int)num +
- i * 2);
+ sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
if (s != NULL)
diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c
index 4a81f81c88..39c9a61e59 100644
--- a/crypto/asn1/f_int.c
+++ b/crypto/asn1/f_int.c
@@ -166,8 +166,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
i /= 2;
if (num + i > slen) {
if (s == NULL)
- sp = (unsigned char *)OPENSSL_malloc((unsigned int)num +
- i * 2);
+ sp = OPENSSL_malloc((unsigned int)num + i * 2);
else
sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
if (sp == NULL) {
diff --git a/crypto/asn1/f_string.c b/crypto/asn1/f_string.c
index 6a6cf34714..6cb4cfdff9 100644
--- a/crypto/asn1/f_string.c
+++ b/crypto/asn1/f_string.c
@@ -158,12 +158,9 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
i /= 2;
if (num + i > slen) {
if (s == NULL)
- sp = (unsigned char *)OPENSSL_malloc((unsigned int)num +
- i * 2);
+ sp = OPENSSL_malloc((unsigned int)num + i * 2);
else
- sp = (unsigned char *)OPENSSL_realloc(s,
- (unsigned int)num +
- i * 2);
+ sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
if (s != NULL)
diff --git a/crypto/asn1/n_pkey.c b/crypto/asn1/n_pkey.c
index cd6391e941..0d8480b8dd 100644
--- a/crypto/asn1/n_pkey.c
+++ b/crypto/asn1/n_pkey.c
@@ -167,7 +167,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
}
/* Since its RC4 encrypted length is actual length */
- if ((zz = (unsigned char *)OPENSSL_malloc(rsalen)) == NULL) {
+ if ((zz = OPENSSL_malloc(rsalen)) == NULL) {
ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE);
goto err;
}
diff --git a/crypto/asn1/t_x509.c b/crypto/asn1/t_x509.c
index e97222021f..da73b6dfc8 100644
--- a/crypto/asn1/t_x509.c
+++ b/crypto/asn1/t_x509.c
@@ -268,7 +268,7 @@ int X509_ocspid_print(BIO *bp, X509 *x)
if (BIO_printf(bp, " Subject OCSP hash: ") <= 0)
goto err;
derlen = i2d_X509_NAME(x->cert_info->subject, NULL);
- if ((der = dertmp = (unsigned char *)OPENSSL_malloc(derlen)) == NULL)
+ if ((der = dertmp = OPENSSL_malloc(derlen)) == NULL)
goto err;
i2d_X509_NAME(x->cert_info->subject, &dertmp);
diff --git a/crypto/asn1/x_info.c b/crypto/asn1/x_info.c
index a847277b49..fff54c808e 100644
--- a/crypto/asn1/x_info.c
+++ b/crypto/asn1/x_info.c
@@ -66,7 +66,7 @@ X509_INFO *X509_INFO_new(void)
{
X509_INFO *ret = NULL;
- ret = (X509_INFO *)OPENSSL_malloc(sizeof(X509_INFO));
+ ret = OPENSSL_malloc(sizeof(X509_INFO));
if (ret == NULL) {
ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index 0e998d656a..d82385a06c 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -93,15 +93,15 @@ static int buffer_new(BIO *bi)
{
BIO_F_BUFFER_CTX *ctx;
- ctx = (BIO_F_BUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
+ ctx = OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
if (ctx == NULL)
return (0);
- ctx->ibuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
+ ctx->ibuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
if (ctx->ibuf == NULL) {
OPENSSL_free(ctx);
return (0);
}
- ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
+ ctx->obuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
if (ctx->obuf == NULL) {
OPENSSL_free(ctx->ibuf);
OPENSSL_free(ctx);
@@ -366,12 +366,12 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
p1 = ctx->ibuf;
p2 = ctx->obuf;
if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) {
- p1 = (char *)OPENSSL_malloc((int)num);
+ p1 = OPENSSL_malloc((int)num);
if (p1 == NULL)
goto malloc_error;
}
if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) {
- p2 = (char *)OPENSSL_malloc((int)num);
+ p2 = OPENSSL_malloc((int)num);
if (p2 == NULL) {
if (p1 != ctx->ibuf)
OPENSSL_free(p1);
diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c
index 3b75b7efc8..ef12820b50 100644
--- a/crypto/bio/bf_lbuf.c
+++ b/crypto/bio/bf_lbuf.c
@@ -104,10 +104,10 @@ static int linebuffer_new(BIO *bi)
{
BIO_LINEBUFFER_CTX *ctx;
- ctx = (BIO_LINEBUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
+ ctx = OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
if (ctx == NULL)
return (0);
- ctx->obuf = (char *)OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
+ ctx->obuf = OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
if (ctx->obuf == NULL) {
OPENSSL_free(ctx);
return (0);
@@ -278,7 +278,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
obs = (int)num;
p = ctx->obuf;
if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) {