From b196e7d936fb377d9c5b305748ac25ff0e53ef6d Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Tue, 28 Apr 2015 15:28:14 -0400 Subject: [PATCH] remove malloc casts Following ANSI C rules, remove the casts from calls to OPENSSL_malloc and OPENSSL_realloc. Reviewed-by: Richard Levitte --- apps/apps.c | 7 +++---- apps/ca.c | 21 +++++++++------------ apps/dgst.c | 2 +- apps/dhparam.c | 2 +- apps/dsaparam.c | 2 +- apps/ecparam.c | 3 +-- apps/enc.c | 2 +- apps/rsa.c | 2 +- apps/s_client.c | 2 +- apps/s_server.c | 4 ++-- apps/s_socket.c | 2 +- apps/speed.c | 6 ++---- apps/srp.c | 3 +-- apps/vms_decc_init.c | 2 +- crypto/asn1/a_bitstr.c | 7 +++---- crypto/asn1/a_digest.c | 2 +- crypto/asn1/a_enum.c | 3 +-- crypto/asn1/a_i2d_fp.c | 2 +- crypto/asn1/a_int.c | 7 +++---- crypto/asn1/a_object.c | 4 ++-- crypto/asn1/a_sign.c | 4 ++-- crypto/asn1/asn1_lib.c | 2 +- crypto/asn1/asn_mime.c | 4 ++-- crypto/asn1/f_enum.c | 7 ++----- crypto/asn1/f_int.c | 3 +-- crypto/asn1/f_string.c | 7 ++----- crypto/asn1/n_pkey.c | 2 +- crypto/asn1/t_x509.c | 2 +- crypto/asn1/x_info.c | 2 +- crypto/bio/bf_buff.c | 10 +++++----- crypto/bio/bf_lbuf.c | 6 +++--- crypto/bio/bf_nbio.c | 2 +- crypto/bio/bio_lib.c | 2 +- crypto/bio/bss_acpt.c | 2 +- crypto/bio/bss_conn.c | 2 +- crypto/bio/bss_log.c | 2 +- crypto/bn/bn_blind.c | 2 +- crypto/bn/bn_exp.c | 3 +-- crypto/bn/bn_gf2m.c | 10 +++++----- crypto/bn/bn_lib.c | 6 +++--- crypto/bn/bn_mont.c | 2 +- crypto/bn/bn_print.c | 7 +++---- crypto/bn/bn_rand.c | 2 +- crypto/bn/bn_recp.c | 2 +- crypto/comp/c_zlib.c | 3 +-- crypto/comp/comp_lib.c | 2 +- crypto/conf/conf_def.c | 6 +++--- crypto/dh/dh_lib.c | 3 +-- crypto/dsa/dsa_ameth.c | 2 +- crypto/dsa/dsa_lib.c | 2 +- crypto/dso/dso_lib.c | 5 +++-- crypto/dso/dso_win32.c | 2 +- crypto/ec/ec_ameth.c | 2 +- crypto/ec/ec_key.c | 2 +- crypto/ec/ec_mult.c | 2 +- crypto/ec/ec_print.c | 2 +- crypto/ec/ecp_nistp224.c | 2 +- crypto/ec/ecp_nistp256.c | 2 +- crypto/ec/ecp_nistp521.c | 2 +- crypto/ec/ecp_nistz256.c | 2 +- crypto/ecdh/ech_lib.c | 2 +- crypto/ecdsa/ecs_lib.c | 2 +- crypto/engine/eng_cryptodev.c | 2 +- crypto/engine/eng_lib.c | 2 +- crypto/err/err.c | 2 +- crypto/evp/bio_b64.c | 2 +- crypto/evp/bio_enc.c | 2 +- crypto/evp/bio_ok.c | 2 +- crypto/evp/evp_pbe.c | 2 +- crypto/evp/p_lib.c | 2 +- crypto/evp/p_open.c | 2 +- crypto/ex_data.c | 3 +-- crypto/lhash/lhash.c | 15 ++++++--------- crypto/lock.c | 2 +- crypto/mem.c | 2 +- crypto/mem_dbg.c | 4 ++-- crypto/modes/gcm128.c | 2 +- crypto/modes/ocb128.c | 2 +- crypto/objects/o_names.c | 2 +- crypto/objects/obj_dat.c | 14 ++++++-------- crypto/pem/pem_lib.c | 2 +- crypto/pem/pem_seal.c | 4 ++-- crypto/pem/pem_sign.c | 2 +- crypto/pqueue/pqueue.c | 4 ++-- crypto/rsa/rsa_ameth.c | 2 +- crypto/rsa/rsa_lib.c | 2 +- crypto/rsa/rsa_saos.c | 4 ++-- crypto/rsa/rsa_sign.c | 4 ++-- crypto/srp/srp_vfy.c | 7 +++---- crypto/stack/stack.c | 5 ++--- crypto/store/str_lib.c | 4 ++-- crypto/store/str_mem.c | 3 +-- crypto/store/str_meth.c | 3 +-- crypto/ts/ts_rsp_sign.c | 4 ++-- crypto/ts/ts_verify_ctx.c | 4 ++-- crypto/ui/ui_lib.c | 9 ++++----- crypto/x509/by_dir.c | 2 +- crypto/x509/x509_lu.c | 8 ++++---- crypto/x509/x509_req.c | 2 +- crypto/x509/x509_vfy.c | 3 ++- crypto/x509v3/v3_lib.c | 4 +--- crypto/x509v3/v3_utl.c | 2 +- demos/b64.c | 2 +- engines/ccgost/gost_crypt.c | 2 +- engines/e_cswift.c | 2 +- ssl/bio_ssl.c | 2 +- ssl/d1_both.c | 7 +++---- ssl/ssl_cert.c | 4 ++-- ssl/ssl_ciph.c | 7 +++---- ssl/ssl_lib.c | 4 ++-- ssl/ssl_sess.c | 4 ++-- ssl/t1_enc.c | 4 ++-- test/dhtest.c | 4 ++-- test/ecdhtest.c | 4 ++-- 114 files changed, 191 insertions(+), 226 deletions(-) diff --git a/apps/apps.c b/apps/apps.c index 462e2b650c..66e37962a6 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -180,7 +180,7 @@ int chopup_args(ARGS *arg, char *buf) arg->argc = 0; if (arg->size == 0) { arg->size = 20; - arg->argv = (char **)OPENSSL_malloc(sizeof(char *) * arg->size); + arg->argv = OPENSSL_malloc(sizeof(char *) * arg->size); if (arg->argv == NULL) return 0; } @@ -195,8 +195,7 @@ int chopup_args(ARGS *arg, char *buf) /* The start of something good :-) */ if (arg->argc >= arg->size) { arg->size += 20; - arg->argv = (char **)OPENSSL_realloc(arg->argv, - sizeof(char *) * arg->size); + arg->argv = OPENSSL_realloc(arg->argv, sizeof(char *) * arg->size); if (arg->argv == NULL) return 0; } @@ -368,7 +367,7 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp) ok = UI_add_input_string(ui, prompt, ui_flags, buf, PW_MIN_LENGTH, bufsiz - 1); if (ok >= 0 && verify) { - buff = (char *)OPENSSL_malloc(bufsiz); + buff = OPENSSL_malloc(bufsiz); if (!buff) { BIO_printf(bio_err, "Out of memory\n"); UI_free(ui); diff --git a/apps/ca.c b/apps/ca.c index 218a407338..ac720dbeea 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -1986,17 +1986,17 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, goto end; /* We now just add it to the database */ - row[DB_type] = (char *)OPENSSL_malloc(2); + row[DB_type] = OPENSSL_malloc(2); tm = X509_get_notAfter(ret); - row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1); + row[DB_exp_date] = OPENSSL_malloc(tm->length + 1); memcpy(row[DB_exp_date], tm->data, tm->length); row[DB_exp_date][tm->length] = '\0'; row[DB_rev_date] = NULL; /* row[DB_serial] done already */ - row[DB_file] = (char *)OPENSSL_malloc(8); + row[DB_file] = OPENSSL_malloc(8); row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0); if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) || @@ -2008,8 +2008,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, row[DB_type][0] = 'V'; row[DB_type][1] = '\0'; - if ((irow = - (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { + if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); goto end; } @@ -2242,17 +2241,17 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value) row[DB_serial], row[DB_name]); /* We now just add it to the database */ - row[DB_type] = (char *)OPENSSL_malloc(2); + row[DB_type] = OPENSSL_malloc(2); tm = X509_get_notAfter(x509); - row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1); + row[DB_exp_date] = OPENSSL_malloc(tm->length + 1); memcpy(row[DB_exp_date], tm->data, tm->length); row[DB_exp_date][tm->length] = '\0'; row[DB_rev_date] = NULL; /* row[DB_serial] done already */ - row[DB_file] = (char *)OPENSSL_malloc(8); + row[DB_file] = OPENSSL_malloc(8); /* row[DB_name] done already */ @@ -2265,9 +2264,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value) row[DB_type][0] = 'V'; row[DB_type][1] = '\0'; - if ((irow = - (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == - NULL) { + if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); goto end; } @@ -2406,7 +2403,7 @@ static int do_updatedb(CA_DB *db) /* get actual time and make a string */ a_tm = X509_gmtime_adj(a_tm, 0); - a_tm_s = (char *)OPENSSL_malloc(a_tm->length + 1); + a_tm_s = OPENSSL_malloc(a_tm->length + 1); if (a_tm_s == NULL) { cnt = -1; goto end; diff --git a/apps/dgst.c b/apps/dgst.c index adfa2a63ba..106e939fbf 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -139,7 +139,7 @@ int dgst_main(int argc, char **argv) int engine_impl = 0; prog = opt_progname(argv[0]); - if ((buf = (unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL) { + if ((buf = OPENSSL_malloc(BUFSIZE)) == NULL) { BIO_printf(bio_err, "%s: out of memory\n", prog); goto end; } diff --git a/apps/dhparam.c b/apps/dhparam.c index 6e51c0b82e..e7fa7ae26f 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -379,7 +379,7 @@ int dhparam_main(int argc, char **argv) len = BN_num_bytes(dh->p); bits = BN_num_bits(dh->p); - data = (unsigned char *)OPENSSL_malloc(len); + data = OPENSSL_malloc(len); if (data == NULL) { perror("OPENSSL_malloc"); goto end; diff --git a/apps/dsaparam.c b/apps/dsaparam.c index f7365b92d0..5aa6e2ccfc 100644 --- a/apps/dsaparam.c +++ b/apps/dsaparam.c @@ -273,7 +273,7 @@ int dsaparam_main(int argc, char **argv) len = BN_num_bytes(dsa->p); bits_p = BN_num_bits(dsa->p); - data = (unsigned char *)OPENSSL_malloc(len + 20); + data = OPENSSL_malloc(len + 20); if (data == NULL) { perror("OPENSSL_malloc"); goto end; diff --git a/apps/ecparam.c b/apps/ecparam.c index 049fc78092..f316793cd3 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -388,8 +388,7 @@ int ecparam_main(int argc, char **argv) if ((tmp_len = (size_t)BN_num_bytes(ec_cofactor)) > buf_len) buf_len = tmp_len; - buffer = (unsigned char *)OPENSSL_malloc(buf_len); - + buffer = OPENSSL_malloc(buf_len); if (buffer == NULL) { perror("OPENSSL_malloc"); goto end; diff --git a/apps/enc.c b/apps/enc.c index 61a64d4469..794fce1f3d 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -314,7 +314,7 @@ int enc_main(int argc, char **argv) BIO_printf(bio_err, "bufsize=%d\n", bsize); strbuf = OPENSSL_malloc(SIZE); - buff = (unsigned char *)OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize)); + buff = OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize)); if ((buff == NULL) || (strbuf == NULL)) { BIO_printf(bio_err, "OPENSSL_malloc failure %ld\n", (long)EVP_ENCODE_LENGTH(bsize)); diff --git a/apps/rsa.c b/apps/rsa.c index 8e93dd2f97..c8b05e60ce 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -349,7 +349,7 @@ int rsa_main(int argc, char **argv) i = 1; size = i2d_RSA_NET(rsa, NULL, NULL, 0); - if ((p = (unsigned char *)OPENSSL_malloc(size)) == NULL) { + if ((p = OPENSSL_malloc(size)) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); goto end; } diff --git a/apps/s_client.c b/apps/s_client.c index 431a1069d7..9181c759b8 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -385,7 +385,7 @@ static int ssl_srp_verify_param_cb(SSL *s, void *arg) static char *ssl_give_srp_client_pwd_cb(SSL *s, void *arg) { SRP_ARG *srp_arg = (SRP_ARG *)arg; - char *pass = (char *)OPENSSL_malloc(PWD_STRLEN + 1); + char *pass = OPENSSL_malloc(PWD_STRLEN + 1); PW_CB_DATA cb_tmp; int l; diff --git a/apps/s_server.c b/apps/s_server.c index e12db0c866..fb6fd3dbf7 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -461,7 +461,7 @@ static int ebcdic_new(BIO *bi) { EBCDIC_OUTBUFF *wbuf; - wbuf = (EBCDIC_OUTBUFF *) OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + 1024); + wbuf = OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + 1024); if (!wbuf) return 0; wbuf->alloced = 1024; @@ -518,7 +518,7 @@ static int ebcdic_write(BIO *b, const char *in, int inl) num = num + num; /* double the size */ if (num < inl) num = inl; - wbuf = (EBCDIC_OUTBUFF *) OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num); + wbuf = OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num); if (!wbuf) return 0; OPENSSL_free(b->ptr); diff --git a/apps/s_socket.c b/apps/s_socket.c index 4c440dc50a..050426a0a4 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -562,7 +562,7 @@ static int do_accept(int acc_sock, int *sock, char **host) *host = NULL; /* return(0); */ } else { - if ((*host = (char *)OPENSSL_malloc(strlen(h1->h_name) + 1)) == NULL) { + if ((*host = OPENSSL_malloc(strlen(h1->h_name) + 1)) == NULL) { perror("OPENSSL_malloc"); closesocket(ret); return (0); diff --git a/apps/speed.c b/apps/speed.c index 57587053cc..7dfdda8bf5 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -791,13 +791,11 @@ int speed_main(int argc, char **argv) ecdh_doit[i] = 0; #endif - if ((buf_malloc = - (unsigned char *)OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) { + if ((buf_malloc = OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) { BIO_printf(bio_err, "out of memory\n"); goto end; } - if ((buf2_malloc = - (unsigned char *)OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) { + if ((buf2_malloc = OPENSSL_malloc((int)BUFSIZE + misalign)) == NULL) { BIO_printf(bio_err, "out of memory\n"); goto end; } diff --git a/apps/srp.c b/apps/srp.c index c62d55de2b..0acbb8ac85 100644 --- a/apps/srp.c +++ b/apps/srp.c @@ -138,8 +138,7 @@ static int update_index(CA_DB *db, BIO *bio, char **row) char **irow; int i; - if ((irow = - (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { + if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); return 0; } diff --git a/apps/vms_decc_init.c b/apps/vms_decc_init.c index 3c953aa361..1717dae37e 100644 --- a/apps/vms_decc_init.c +++ b/apps/vms_decc_init.c @@ -130,7 +130,7 @@ char **copy_argv(int *argc, char *argv[]) */ int i, count = *argc; - char **newargv = (char **)OPENSSL_malloc((count + 1) * sizeof *newargv); + char **newargv = OPENSSL_malloc((count + 1) * sizeof *newargv); for (i = 0; i < count; i++) newargv[i] = argv[i]; 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)) { - p = (char *)OPENSSL_malloc((int)num); + p = OPENSSL_malloc((int)num); if (p == NULL) goto malloc_error; } diff --git a/crypto/bio/bf_nbio.c b/crypto/bio/bf_nbio.c index 0ba6055e07..df547a1027 100644 --- a/crypto/bio/bf_nbio.c +++ b/crypto/bio/bf_nbio.c @@ -102,7 +102,7 @@ static int nbiof_new(BIO *bi) { NBIO_TEST *nt; - if (!(nt = (NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST)))) + if (!(nt = OPENSSL_malloc(sizeof(NBIO_TEST)))) return (0); nt->lrn = -1; nt->lwn = -1; diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index a5d8680d48..e7957a7678 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -67,7 +67,7 @@ BIO *BIO_new(BIO_METHOD *method) { BIO *ret = NULL; - ret = (BIO *)OPENSSL_malloc(sizeof(BIO)); + ret = OPENSSL_malloc(sizeof(BIO)); if (ret == NULL) { BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index 72f7bd21de..d6f66789d8 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -137,7 +137,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void) { BIO_ACCEPT *ret; - if ((ret = (BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL) + if ((ret = OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL) return (NULL); memset(ret, 0, sizeof(BIO_ACCEPT)); diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c index e95b4b38d6..e44bb32dca 100644 --- a/crypto/bio/bss_conn.c +++ b/crypto/bio/bss_conn.c @@ -287,7 +287,7 @@ BIO_CONNECT *BIO_CONNECT_new(void) { BIO_CONNECT *ret; - if ((ret = (BIO_CONNECT *)OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL) + if ((ret = OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL) return (NULL); ret->state = BIO_CONN_S_BEFORE; ret->param_hostname = NULL; diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c index 5f9ab5729f..2399ff8b10 100644 --- a/crypto/bio/bss_log.c +++ b/crypto/bio/bss_log.c @@ -239,7 +239,7 @@ static int slg_write(BIO *b, const char *in, int inl) /* The default */ }; - if ((buf = (char *)OPENSSL_malloc(inl + 1)) == NULL) { + if ((buf = OPENSSL_malloc(inl + 1)) == NULL) { return (0); } strncpy(buf, in, inl); diff --git a/crypto/bn/bn_blind.c b/crypto/bn/bn_blind.c index 1cd6fb8ede..f045904f76 100644 --- a/crypto/bn/bn_blind.c +++ b/crypto/bn/bn_blind.c @@ -137,7 +137,7 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) bn_check_top(mod); - if ((ret = (BN_BLINDING *)OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) { + if ((ret = OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) { BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 8c46e50bdc..153a970d05 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -758,8 +758,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, else #endif if ((powerbufFree = - (unsigned char *)OPENSSL_malloc(powerbufLen + - MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) + OPENSSL_malloc(powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) goto err; diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index aeee49a015..fc7ad24296 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -551,7 +551,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, bn_check_top(a); bn_check_top(b); bn_check_top(p); - if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) + if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -610,7 +610,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) + if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1027,7 +1027,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, bn_check_top(a); bn_check_top(b); bn_check_top(p); - if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) + if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1087,7 +1087,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int *arr = NULL; bn_check_top(a); bn_check_top(p); - if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) + if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1218,7 +1218,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, int *arr = NULL; bn_check_top(a); bn_check_top(p); - if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) + if ((arr = OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index c3164fa8aa..9cffba8b47 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -268,7 +268,7 @@ BIGNUM *BN_new(void) { BIGNUM *ret; - if ((ret = (BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL) { + if ((ret = OPENSSL_malloc(sizeof(BIGNUM))) == NULL) { BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } @@ -299,7 +299,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words) BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); return (NULL); } - a = A = (BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG) * words); + a = A = OPENSSL_malloc(sizeof(BN_ULONG) * words); if (A == NULL) { BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE); return (NULL); @@ -921,7 +921,7 @@ BN_GENCB *BN_GENCB_new(void) { BN_GENCB *ret; - if ((ret = (BN_GENCB *)OPENSSL_malloc(sizeof(BN_GENCB))) == NULL) { + if ((ret = OPENSSL_malloc(sizeof(BN_GENCB))) == NULL) { BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index 45deed7558..f19910dc46 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -314,7 +314,7 @@ BN_MONT_CTX *BN_MONT_CTX_new(void) { BN_MONT_CTX *ret; - if ((ret = (BN_MONT_CTX *)OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL) + if ((ret = OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL) return (NULL); BN_MONT_CTX_init(ret); diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c index 1000e69a86..9b03240e6d 100644 --- a/crypto/bn/bn_print.c +++ b/crypto/bn/bn_print.c @@ -71,7 +71,7 @@ char *BN_bn2hex(const BIGNUM *a) char *buf; char *p; - buf = (char *)OPENSSL_malloc(a->top * BN_BYTES * 2 + 2); + buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2); if (buf == NULL) { BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE); goto err; @@ -114,9 +114,8 @@ char *BN_bn2dec(const BIGNUM *a) */ i = BN_num_bits(a) * 3; num = (i / 10 + i / 1000 + 1) + 1; - bn_data = - (BN_ULONG *)OPENSSL_malloc((num / BN_DEC_NUM + 1) * sizeof(BN_ULONG)); - buf = (char *)OPENSSL_malloc(num + 3); + bn_data = OPENSSL_malloc((num / BN_DEC_NUM + 1) * sizeof(BN_ULONG)); + buf = OPENSSL_malloc(num + 3); if ((buf == NULL) || (bn_data == NULL)) { BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index be58a5ab2f..10964646f2 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -131,7 +131,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) bit = (bits - 1) % 8; mask = 0xff << (bit + 1); - buf = (unsigned char *)OPENSSL_malloc(bytes); + buf = OPENSSL_malloc(bytes); if (buf == NULL) { BNerr(BN_F_BNRAND, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 4f94408b5d..ef1972b227 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -71,7 +71,7 @@ BN_RECP_CTX *BN_RECP_CTX_new(void) { BN_RECP_CTX *ret; - if ((ret = (BN_RECP_CTX *)OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL) + if ((ret = OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL) return (NULL); BN_RECP_CTX_init(ret); diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index c3b064cc6e..aa03f8fda1 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -119,8 +119,7 @@ static int zlib_stateful_ex_idx = -1; static int zlib_stateful_init(COMP_CTX *ctx) { int err; - struct zlib_state *state = - (struct zlib_state *)OPENSSL_malloc(sizeof(struct zlib_state)); + struct zlib_state *state = OPENSSL_malloc(sizeof(struct zlib_state)); if (state == NULL) goto err; diff --git a/crypto/comp/comp_lib.c b/crypto/comp/comp_lib.c index bd4eb7a1ab..7bcdd6b496 100644 --- a/crypto/comp/comp_lib.c +++ b/crypto/comp/comp_lib.c @@ -8,7 +8,7 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) { COMP_CTX *ret; - if ((ret = (COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) { + if ((ret = OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) { /* ZZZZZZZZZZZZZZZZ */ return (NULL); } diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index c8744e6708..ef3fef4400 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -225,7 +225,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) goto err; } - section = (char *)OPENSSL_malloc(10); + section = OPENSSL_malloc(10); if (section == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; @@ -357,13 +357,13 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) p++; *p = '\0'; - if (!(v = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) { + if (!(v = OPENSSL_malloc(sizeof(CONF_VALUE)))) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } if (psection == NULL) psection = section; - v->name = (char *)OPENSSL_malloc(strlen(pname) + 1); + v->name = OPENSSL_malloc(strlen(pname) + 1); v->value = NULL; if (v->name == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index 4f07a277ea..68a54a6fd2 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -109,9 +109,8 @@ DH *DH_new(void) DH *DH_new_method(ENGINE *engine) { - DH *ret; + DH *ret = OPENSSL_malloc(sizeof(DH)); - ret = (DH *)OPENSSL_malloc(sizeof(DH)); if (ret == NULL) { DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 65e07fd329..c155e5b519 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -451,7 +451,7 @@ static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) update_buflen(priv_key, &buf_len); update_buflen(pub_key, &buf_len); - m = (unsigned char *)OPENSSL_malloc(buf_len + 10); + m = OPENSSL_malloc(buf_len + 10); if (m == NULL) { DSAerr(DSA_F_DO_DSA_PRINT, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index c94be9d5df..5cf1824897 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -117,7 +117,7 @@ DSA *DSA_new_method(ENGINE *engine) { DSA *ret; - ret = (DSA *)OPENSSL_malloc(sizeof(DSA)); + ret = OPENSSL_malloc(sizeof(DSA)); if (ret == NULL) { DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c index 09b8eafcca..c1d6d2544f 100644 --- a/crypto/dso/dso_lib.c +++ b/crypto/dso/dso_lib.c @@ -96,14 +96,15 @@ DSO *DSO_new_method(DSO_METHOD *meth) { DSO *ret; - if (default_DSO_meth == NULL) + if (default_DSO_meth == NULL) { /* * We default to DSO_METH_openssl() which in turn defaults to * stealing the "best available" method. Will fallback to * DSO_METH_null() in the worst case. */ default_DSO_meth = DSO_METHOD_openssl(); - ret = (DSO *)OPENSSL_malloc(sizeof(DSO)); + } + ret = OPENSSL_malloc(sizeof(DSO)); if (ret == NULL) { DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c index e671672920..2499fc152b 100644 --- a/crypto/dso/dso_win32.c +++ b/crypto/dso/dso_win32.c @@ -168,7 +168,7 @@ static int win32_load(DSO *dso) ERR_add_error_data(3, "filename(", filename, ")"); goto err; } - p = (HINSTANCE *) OPENSSL_malloc(sizeof(HINSTANCE)); + p = OPENSSL_malloc(sizeof(HINSTANCE)); if (p == NULL) { DSOerr(DSO_F_WIN32_LOAD, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 65c3d569ab..5a7b0b744f 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -324,7 +324,7 @@ static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); return 0; } - ep = (unsigned char *)OPENSSL_malloc(eplen); + ep = OPENSSL_malloc(eplen); if (!ep) { EC_KEY_set_enc_flags(ec_key, old_flags); ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index a74ccf70f2..b73263d6c1 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -69,7 +69,7 @@ EC_KEY *EC_KEY_new(void) { EC_KEY *ret; - ret = (EC_KEY *)OPENSSL_malloc(sizeof(EC_KEY)); + ret = OPENSSL_malloc(sizeof(EC_KEY)); if (ret == NULL) { ECerr(EC_F_EC_KEY_NEW, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 243b5392e0..979b4540ef 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -100,7 +100,7 @@ static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group) if (!group) return NULL; - ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP)); + ret = OPENSSL_malloc(sizeof(EC_PRE_COMP)); if (!ret) { ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; diff --git a/crypto/ec/ec_print.c b/crypto/ec/ec_print.c index 7c34694633..5ae85ccdb0 100644 --- a/crypto/ec/ec_print.c +++ b/crypto/ec/ec_print.c @@ -143,7 +143,7 @@ char *EC_POINT_point2hex(const EC_GROUP *group, return NULL; } - ret = (char *)OPENSSL_malloc(buf_len * 2 + 2); + ret = OPENSSL_malloc(buf_len * 2 + 2); if (ret == NULL) { OPENSSL_free(buf); return NULL; diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index 6269cce612..5afe71c70c 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -1200,7 +1200,7 @@ static void batch_mul(felem x_out, felem y_out, felem z_out, static NISTP224_PRE_COMP *nistp224_pre_comp_new() { NISTP224_PRE_COMP *ret = NULL; - ret = (NISTP224_PRE_COMP *) OPENSSL_malloc(sizeof *ret); + ret = OPENSSL_malloc(sizeof *ret); if (!ret) { ECerr(EC_F_NISTP224_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index b42e96a814..2f394bf88e 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -1815,7 +1815,7 @@ const EC_METHOD *EC_GFp_nistp256_method(void) static NISTP256_PRE_COMP *nistp256_pre_comp_new() { NISTP256_PRE_COMP *ret = NULL; - ret = (NISTP256_PRE_COMP *) OPENSSL_malloc(sizeof *ret); + ret = OPENSSL_malloc(sizeof *ret); if (!ret) { ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 2e4a651c72..b2fe653f1e 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -1644,7 +1644,7 @@ const EC_METHOD *EC_GFp_nistp521_method(void) static NISTP521_PRE_COMP *nistp521_pre_comp_new() { NISTP521_PRE_COMP *ret = NULL; - ret = (NISTP521_PRE_COMP *) OPENSSL_malloc(sizeof(NISTP521_PRE_COMP)); + ret = OPENSSL_malloc(sizeof(NISTP521_PRE_COMP)); if (!ret) { ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c index 6937314690..c527797341 100644 --- a/crypto/ec/ecp_nistz256.c +++ b/crypto/ec/ecp_nistz256.c @@ -1416,7 +1416,7 @@ static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group) if (!group) return NULL; - ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP)); + ret = OPENSSL_malloc(sizeof(EC_PRE_COMP)); if (!ret) { ECerr(EC_F_ECP_NISTZ256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c index 51473682a4..7b57ec4ecd 100644 --- a/crypto/ecdh/ech_lib.c +++ b/crypto/ecdh/ech_lib.c @@ -117,7 +117,7 @@ static ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine) { ECDH_DATA *ret; - ret = (ECDH_DATA *)OPENSSL_malloc(sizeof(ECDH_DATA)); + ret = OPENSSL_malloc(sizeof(ECDH_DATA)); if (ret == NULL) { ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c index 67e521fb8a..cdb7b6038e 100644 --- a/crypto/ecdsa/ecs_lib.c +++ b/crypto/ecdsa/ecs_lib.c @@ -105,7 +105,7 @@ static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine) { ECDSA_DATA *ret; - ret = (ECDSA_DATA *)OPENSSL_malloc(sizeof(ECDSA_DATA)); + ret = OPENSSL_malloc(sizeof(ECDSA_DATA)); if (ret == NULL) { ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c index d005e017e4..a3be0d79ed 100644 --- a/crypto/engine/eng_cryptodev.c +++ b/crypto/engine/eng_cryptodev.c @@ -1045,7 +1045,7 @@ static int crparam2bn(struct crparam *crp, BIGNUM *a) if (bytes == 0) return (-1); - if ((pd = (u_int8_t *) OPENSSL_malloc(bytes)) == NULL) + if ((pd = OPENSSL_malloc(bytes)) == NULL) return (-1); for (i = 0; i < bytes; i++) diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c index dc2abd28ec..608344064e 100644 --- a/crypto/engine/eng_lib.c +++ b/crypto/engine/eng_lib.c @@ -66,7 +66,7 @@ ENGINE *ENGINE_new(void) { ENGINE *ret; - ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE)); + ret = OPENSSL_malloc(sizeof(ENGINE)); if (ret == NULL) { ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE); return NULL; diff --git a/crypto/err/err.c b/crypto/err/err.c index b078442109..4752148169 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -886,7 +886,7 @@ ERR_STATE *ERR_get_state(void) /* ret == the error state, if NULL, make a new one */ if (ret == NULL) { - ret = (ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE)); + ret = OPENSSL_malloc(sizeof(ERR_STATE)); if (ret == NULL) return (&fallback); CRYPTO_THREADID_cpy(&ret->tid, &tid); diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c index 8cbbf0253b..fe772fc34f 100644 --- a/crypto/evp/bio_b64.c +++ b/crypto/evp/bio_b64.c @@ -115,7 +115,7 @@ static int b64_new(BIO *bi) { BIO_B64_CTX *ctx; - ctx = (BIO_B64_CTX *)OPENSSL_malloc(sizeof(BIO_B64_CTX)); + ctx = OPENSSL_malloc(sizeof(BIO_B64_CTX)); if (ctx == NULL) return (0); diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c index faaed4de92..4409a91242 100644 --- a/crypto/evp/bio_enc.c +++ b/crypto/evp/bio_enc.c @@ -112,7 +112,7 @@ static int enc_new(BIO *bi) { BIO_ENC_CTX *ctx; - ctx = (BIO_ENC_CTX *)OPENSSL_malloc(sizeof(BIO_ENC_CTX)); + ctx = OPENSSL_malloc(sizeof(BIO_ENC_CTX)); if (ctx == NULL) return (0); EVP_CIPHER_CTX_init(&ctx->cipher); diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c index ffdde6cf79..1aab2004ef 100644 --- a/crypto/evp/bio_ok.c +++ b/crypto/evp/bio_ok.c @@ -176,7 +176,7 @@ static int ok_new(BIO *bi) { BIO_OK_CTX *ctx; - ctx = (BIO_OK_CTX *)OPENSSL_malloc(sizeof(BIO_OK_CTX)); + ctx = OPENSSL_malloc(sizeof(BIO_OK_CTX)); if (ctx == NULL) return (0); diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index 7db9511452..00fa72d8bb 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -228,7 +228,7 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, EVP_PBE_CTL *pbe_tmp; if (!pbe_algs) pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); - if (!(pbe_tmp = (EVP_PBE_CTL *)OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) { + if (!(pbe_tmp = OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) { EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); return 0; } diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index fb8f175fcb..c9e971ed85 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -185,7 +185,7 @@ EVP_PKEY *EVP_PKEY_new(void) { EVP_PKEY *ret; - ret = (EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY)); + ret = OPENSSL_malloc(sizeof(EVP_PKEY)); if (ret == NULL) { EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/crypto/evp/p_open.c b/crypto/evp/p_open.c index 229eb6417a..adaa42fa1e 100644 --- a/crypto/evp/p_open.c +++ b/crypto/evp/p_open.c @@ -88,7 +88,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, } size = RSA_size(priv->pkey.rsa); - key = (unsigned char *)OPENSSL_malloc(size + 2); + key = OPENSSL_malloc(size + 2); if (key == NULL) { /* ERROR */ EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE); diff --git a/crypto/ex_data.c b/crypto/ex_data.c index d55985ba0a..6a567c9924 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -350,8 +350,7 @@ static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp, CRYPTO_EX_free *free_func) { int toret = -1; - CRYPTO_EX_DATA_FUNCS *a = - (CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); + CRYPTO_EX_DATA_FUNCS *a = OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); if (!a) { CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE); return -1; diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index 5e9bfb8b1c..ac3b5f607b 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -188,7 +188,7 @@ void *lh_insert(_LHASH *lh, void *data) rn = getrn(lh, data, &hash); if (*rn == NULL) { - if ((nn = (LHASH_NODE *)OPENSSL_malloc(sizeof(LHASH_NODE))) == NULL) { + if ((nn = OPENSSL_malloc(sizeof(LHASH_NODE))) == NULL) { lh->error++; return (NULL); } @@ -325,15 +325,13 @@ static void expand(_LHASH *lh) if ((lh->p) >= lh->pmax) { j = (int)lh->num_alloc_nodes * 2; - n = (LHASH_NODE **)OPENSSL_realloc(lh->b, - (int)(sizeof(LHASH_NODE *) * j)); + n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j)); if (n == NULL) { -/* fputs("realloc error in lhash",stderr); */ + /* fputs("realloc error in lhash",stderr); */ lh->error++; lh->p = 0; return; } - /* else */ for (i = (int)lh->num_alloc_nodes; i < j; i++) /* 26/02/92 eay */ n[i] = NULL; /* 02/03/92 eay */ lh->pmax = lh->num_alloc_nodes; @@ -351,11 +349,10 @@ static void contract(_LHASH *lh) np = lh->b[lh->p + lh->pmax - 1]; lh->b[lh->p + lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ if (lh->p == 0) { - n = (LHASH_NODE **)OPENSSL_realloc(lh->b, - (unsigned int)(sizeof(LHASH_NODE *) - * lh->pmax)); + n = OPENSSL_realloc(lh->b, + (unsigned int)(sizeof(LHASH_NODE *) * lh->pmax)); if (n == NULL) { -/* fputs("realloc error in lhash",stderr); */ + /* fputs("realloc error in lhash",stderr); */ lh->error++; return; } diff --git a/crypto/lock.c b/crypto/lock.c index c7188780e6..cc5f47a6d6 100644 --- a/crypto/lock.c +++ b/crypto/lock.c @@ -251,7 +251,7 @@ int CRYPTO_get_new_dynlockid(void) } CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); - pointer = (CRYPTO_dynlock *) OPENSSL_malloc(sizeof(CRYPTO_dynlock)); + pointer = OPENSSL_malloc(sizeof(CRYPTO_dynlock)); if (pointer == NULL) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); return (0); diff --git a/crypto/mem.c b/crypto/mem.c index 2251d57fb3..afdce778dc 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -447,7 +447,7 @@ void *CRYPTO_remalloc(void *a, int num, const char *file, int line) { if (a != NULL) OPENSSL_free(a); - a = (char *)OPENSSL_malloc(num); + a = OPENSSL_malloc(num); return (a); } diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 36593ed664..402df01fad 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -394,7 +394,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line) if (is_MemCheck_on()) { MemCheck_off(); /* obtain MALLOC2 lock */ - if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL) { + if ((ami = OPENSSL_malloc(sizeof(APP_INFO))) == NULL) { ret = 0; goto err; } @@ -478,7 +478,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, if (is_MemCheck_on()) { MemCheck_off(); /* make sure we hold MALLOC2 lock */ - if ((m = (MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL) { + if ((m = OPENSSL_malloc(sizeof(MEM))) == NULL) { OPENSSL_free(addr); MemCheck_on(); /* release MALLOC2 lock if num_disabled drops * to 0 */ diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c index 1d1b0d9b16..4ac28b32fb 100644 --- a/crypto/modes/gcm128.c +++ b/crypto/modes/gcm128.c @@ -1701,7 +1701,7 @@ GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block) { GCM128_CONTEXT *ret; - if ((ret = (GCM128_CONTEXT *)OPENSSL_malloc(sizeof(GCM128_CONTEXT)))) + if ((ret = OPENSSL_malloc(sizeof(GCM128_CONTEXT)))) CRYPTO_gcm128_init(ret, key, block); return ret; diff --git a/crypto/modes/ocb128.c b/crypto/modes/ocb128.c index cbcb7f62dd..0d82e5089c 100644 --- a/crypto/modes/ocb128.c +++ b/crypto/modes/ocb128.c @@ -210,7 +210,7 @@ OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, OCB128_CONTEXT *octx; int ret; - if ((octx = (OCB128_CONTEXT *)OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) { + if ((octx = OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) { ret = CRYPTO_ocb128_init(octx, keyenc, keydec, encrypt, decrypt); if (ret) return octx; diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index fa8709fa83..1fa6426a4f 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -187,7 +187,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data) alias = type & OBJ_NAME_ALIAS; type &= ~OBJ_NAME_ALIAS; - onp = (OBJ_NAME *)OPENSSL_malloc(sizeof(OBJ_NAME)); + onp = OPENSSL_malloc(sizeof(OBJ_NAME)); if (onp == NULL) { /* ERROR */ return (0); diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 5c861d1ec2..376169c484 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -255,21 +255,19 @@ int OBJ_add_object(const ASN1_OBJECT *obj) return (0); if ((o = OBJ_dup(obj)) == NULL) goto err; - if (!(ao[ADDED_NID] = (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) + if (!(ao[ADDED_NID] = OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; if ((o->length != 0) && (obj->data != NULL)) if (! - (ao[ADDED_DATA] = (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) + (ao[ADDED_DATA] = OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; if (o->sn != NULL) if (! - (ao[ADDED_SNAME] = - (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) + (ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; if (o->ln != NULL) if (! - (ao[ADDED_LNAME] = - (ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) + (ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2; for (i = ADDED_DATA; i <= ADDED_NID; i++) { @@ -450,7 +448,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) /* Work out total size */ j = ASN1_object_size(0, i, V_ASN1_OBJECT); - if ((buf = (unsigned char *)OPENSSL_malloc(j)) == NULL) + if ((buf = OPENSSL_malloc(j)) == NULL) return NULL; p = buf; @@ -766,7 +764,7 @@ int OBJ_create(const char *oid, const char *sn, const char *ln) if (i <= 0) return (0); - if ((buf = (unsigned char *)OPENSSL_malloc(i)) == NULL) { + if ((buf = OPENSSL_malloc(i)) == NULL) { OBJerr(OBJ_F_OBJ_CREATE, ERR_R_MALLOC_FAILURE); return (0); } diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index 70e6a70772..431e36804f 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -361,7 +361,7 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, } /* dzise + 8 bytes are needed */ /* actually it needs the cipher block size extra... */ - data = (unsigned char *)OPENSSL_malloc((unsigned int)dsize + 20); + data = OPENSSL_malloc((unsigned int)dsize + 20); if (data == NULL) { PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/pem/pem_seal.c b/crypto/pem/pem_seal.c index e82ab6fe42..374273d14f 100644 --- a/crypto/pem/pem_seal.c +++ b/crypto/pem/pem_seal.c @@ -85,7 +85,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, if (j > max) max = j; } - s = (char *)OPENSSL_malloc(max * 2); + s = OPENSSL_malloc(max * 2); if (s == NULL) { PEMerr(PEM_F_PEM_SEALINIT, ERR_R_MALLOC_FAILURE); goto err; @@ -159,7 +159,7 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl, i = RSA_size(priv->pkey.rsa); if (i < 100) i = 100; - s = (unsigned char *)OPENSSL_malloc(i * 2); + s = OPENSSL_malloc(i * 2); if (s == NULL) { PEMerr(PEM_F_PEM_SEALFINAL, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/pem/pem_sign.c b/crypto/pem/pem_sign.c index a3d5c175f9..87cc7273de 100644 --- a/crypto/pem/pem_sign.c +++ b/crypto/pem/pem_sign.c @@ -81,7 +81,7 @@ int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, int i, ret = 0; unsigned int m_len; - m = (unsigned char *)OPENSSL_malloc(EVP_PKEY_size(pkey) + 2); + m = OPENSSL_malloc(EVP_PKEY_size(pkey) + 2); if (m == NULL) { PEMerr(PEM_F_PEM_SIGNFINAL, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/pqueue/pqueue.c b/crypto/pqueue/pqueue.c index 675ac60dba..a4af9f9950 100644 --- a/crypto/pqueue/pqueue.c +++ b/crypto/pqueue/pqueue.c @@ -68,7 +68,7 @@ typedef struct _pqueue { pitem *pitem_new(unsigned char *prio64be, void *data) { - pitem *item = (pitem *)OPENSSL_malloc(sizeof(pitem)); + pitem *item = OPENSSL_malloc(sizeof(pitem)); if (item == NULL) return NULL; @@ -90,7 +90,7 @@ void pitem_free(pitem *item) pqueue_s *pqueue_new() { - pqueue_s *pq = (pqueue_s *)OPENSSL_malloc(sizeof(pqueue_s)); + pqueue_s *pq = OPENSSL_malloc(sizeof(pqueue_s)); if (pq == NULL) return NULL; diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index 379bf4c26c..4e02531ec5 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -206,7 +206,7 @@ static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv) update_buflen(x->iqmp, &buf_len); } - m = (unsigned char *)OPENSSL_malloc(buf_len + 10); + m = OPENSSL_malloc(buf_len + 10); if (m == NULL) { RSAerr(RSA_F_DO_RSA_PRINT, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 57ba1cbef2..5b4ce73453 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -127,7 +127,7 @@ RSA *RSA_new_method(ENGINE *engine) { RSA *ret; - ret = (RSA *)OPENSSL_malloc(sizeof(RSA)); + ret = OPENSSL_malloc(sizeof(RSA)); if (ret == NULL) { RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; diff --git a/crypto/rsa/rsa_saos.c b/crypto/rsa/rsa_saos.c index 0f15f00842..80709f5369 100644 --- a/crypto/rsa/rsa_saos.c +++ b/crypto/rsa/rsa_saos.c @@ -83,7 +83,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type, RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); return (0); } - s = (unsigned char *)OPENSSL_malloc((unsigned int)j + 1); + s = OPENSSL_malloc((unsigned int)j + 1); if (s == NULL) { RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE); return (0); @@ -117,7 +117,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype, return (0); } - s = (unsigned char *)OPENSSL_malloc((unsigned int)siglen); + s = OPENSSL_malloc((unsigned int)siglen); if (s == NULL) { RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index a521d1190a..ec1575ac30 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -116,7 +116,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len, return (0); } if (type != NID_md5_sha1) { - tmps = (unsigned char *)OPENSSL_malloc((unsigned int)j + 1); + tmps = OPENSSL_malloc((unsigned int)j + 1); if (tmps == NULL) { RSAerr(RSA_F_RSA_SIGN, ERR_R_MALLOC_FAILURE); return (0); @@ -181,7 +181,7 @@ int int_rsa_verify(int dtype, const unsigned char *m, return 1; } - s = (unsigned char *)OPENSSL_malloc((unsigned int)siglen); + s = OPENSSL_malloc((unsigned int)siglen); if (s == NULL) { RSAerr(RSA_F_INT_RSA_VERIFY, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c index 82b9a77b14..e8bdbf58b1 100644 --- a/crypto/srp/srp_vfy.c +++ b/crypto/srp/srp_vfy.c @@ -249,7 +249,7 @@ static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v) SRP_VBASE *SRP_VBASE_new(char *seed_key) { - SRP_VBASE *vb = (SRP_VBASE *)OPENSSL_malloc(sizeof(SRP_VBASE)); + SRP_VBASE *vb = OPENSSL_malloc(sizeof(SRP_VBASE)); if (vb == NULL) return NULL; @@ -283,9 +283,8 @@ static SRP_gN_cache *SRP_gN_new_init(const char *ch) { unsigned char tmp[MAX_LEN]; int len; + SRP_gN_cache *newgN = OPENSSL_malloc(sizeof(SRP_gN_cache)); - SRP_gN_cache *newgN = - (SRP_gN_cache *)OPENSSL_malloc(sizeof(SRP_gN_cache)); if (newgN == NULL) return NULL; @@ -391,7 +390,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file) * we add this couple in the internal Stack */ - if ((gN = (SRP_gN *) OPENSSL_malloc(sizeof(SRP_gN))) == NULL) + if ((gN = OPENSSL_malloc(sizeof(SRP_gN))) == NULL) goto err; if (!(gN->id = BUF_strdup(pp[DB_srpid])) diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index 7d97c2cbb4..d4ac91e8fb 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -93,9 +93,8 @@ _STACK *sk_dup(_STACK *sk) if ((ret = sk_new(sk->comp)) == NULL) goto err; - s = (char **)OPENSSL_realloc((char *)ret->data, - (unsigned int)sizeof(char *) * - sk->num_alloc); + s = OPENSSL_realloc((char *)ret->data, + (unsigned int)sizeof(char *) * sk->num_alloc); if (s == NULL) goto err; ret->data = s; diff --git a/crypto/store/str_lib.c b/crypto/store/str_lib.c index d683fd8ecd..1a4f237f06 100644 --- a/crypto/store/str_lib.c +++ b/crypto/store/str_lib.c @@ -109,7 +109,7 @@ STORE *STORE_new_method(const STORE_METHOD *method) return NULL; } - ret = (STORE *)OPENSSL_malloc(sizeof(STORE)); + ret = OPENSSL_malloc(sizeof(STORE)); if (ret == NULL) { STOREerr(STORE_F_STORE_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; @@ -1206,7 +1206,7 @@ struct STORE_attr_info_st { STORE_ATTR_INFO *STORE_ATTR_INFO_new(void) { - return (STORE_ATTR_INFO *)OPENSSL_malloc(sizeof(STORE_ATTR_INFO)); + return OPENSSL_malloc(sizeof(STORE_ATTR_INFO)); } static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs, diff --git a/crypto/store/str_mem.c b/crypto/store/str_mem.c index 8edd0eb41b..f949b34dfb 100644 --- a/crypto/store/str_mem.c +++ b/crypto/store/str_mem.c @@ -244,8 +244,7 @@ static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]) { - struct mem_ctx_st *context = - (struct mem_ctx_st *)OPENSSL_malloc(sizeof(struct mem_ctx_st)); + struct mem_ctx_st *context = OPENSSL_malloc(sizeof(struct mem_ctx_st)); void *attribute_context = NULL; STORE_ATTR_INFO *attrs = NULL; diff --git a/crypto/store/str_meth.c b/crypto/store/str_meth.c index d83a6de0fc..781b1603e3 100644 --- a/crypto/store/str_meth.c +++ b/crypto/store/str_meth.c @@ -63,8 +63,7 @@ STORE_METHOD *STORE_create_method(char *name) { - STORE_METHOD *store_method = - (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD)); + STORE_METHOD *store_method = OPENSSL_malloc(sizeof(STORE_METHOD)); if (store_method) { memset(store_method, 0, sizeof(*store_method)); diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c index 037ab645a2..a8d683bafc 100644 --- a/crypto/ts/ts_rsp_sign.c +++ b/crypto/ts/ts_rsp_sign.c @@ -169,7 +169,7 @@ TS_RESP_CTX *TS_RESP_CTX_new() { TS_RESP_CTX *ctx; - if (!(ctx = (TS_RESP_CTX *)OPENSSL_malloc(sizeof(TS_RESP_CTX)))) { + if (!(ctx = OPENSSL_malloc(sizeof(TS_RESP_CTX)))) { TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } @@ -919,7 +919,7 @@ static int ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc) int len; len = i2d_ESS_SIGNING_CERT(sc, NULL); - if (!(pp = (unsigned char *)OPENSSL_malloc(len))) { + if (!(pp = OPENSSL_malloc(len))) { TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/ts/ts_verify_ctx.c b/crypto/ts/ts_verify_ctx.c index 3e6fcb57be..f328c33053 100644 --- a/crypto/ts/ts_verify_ctx.c +++ b/crypto/ts/ts_verify_ctx.c @@ -63,8 +63,8 @@ TS_VERIFY_CTX *TS_VERIFY_CTX_new(void) { - TS_VERIFY_CTX *ctx = - (TS_VERIFY_CTX *)OPENSSL_malloc(sizeof(TS_VERIFY_CTX)); + TS_VERIFY_CTX *ctx = OPENSSL_malloc(sizeof(TS_VERIFY_CTX)); + if (ctx) memset(ctx, 0, sizeof(TS_VERIFY_CTX)); else diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 06e6cd849c..d2732f5bf2 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -74,9 +74,8 @@ UI *UI_new(void) UI *UI_new_method(const UI_METHOD *method) { - UI *ret; + UI *ret = OPENSSL_malloc(sizeof(UI)); - ret = (UI *)OPENSSL_malloc(sizeof(UI)); if (ret == NULL) { UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; @@ -142,7 +141,7 @@ static UI_STRING *general_allocate_prompt(UI *ui, const char *prompt, } else if ((type == UIT_PROMPT || type == UIT_VERIFY || type == UIT_BOOLEAN) && result_buf == NULL) { UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); - } else if ((ret = (UI_STRING *)OPENSSL_malloc(sizeof(UI_STRING)))) { + } else if ((ret = OPENSSL_malloc(sizeof(UI_STRING)))) { ret->out_string = prompt; ret->flags = prompt_freeable ? OUT_STRING_FREEABLE : 0; ret->input_flags = input_flags; @@ -410,7 +409,7 @@ char *UI_construct_prompt(UI *ui, const char *object_desc, len += sizeof(prompt2) - 1 + strlen(object_name); len += sizeof(prompt3) - 1; - prompt = (char *)OPENSSL_malloc(len + 1); + prompt = OPENSSL_malloc(len + 1); if (prompt == NULL) return NULL; BUF_strlcpy(prompt, prompt1, len + 1); @@ -587,7 +586,7 @@ const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth) UI_METHOD *UI_create_method(char *name) { - UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD)); + UI_METHOD *ui_method = OPENSSL_malloc(sizeof(UI_METHOD)); if (ui_method) { memset(ui_method, 0, sizeof(*ui_method)); diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 80444ffe8a..b30fa30d5f 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -148,7 +148,7 @@ static int new_dir(X509_LOOKUP *lu) { BY_DIR *a; - if ((a = (BY_DIR *)OPENSSL_malloc(sizeof(BY_DIR))) == NULL) + if ((a = OPENSSL_malloc(sizeof(BY_DIR))) == NULL) return (0); if ((a->buffer = BUF_MEM_new()) == NULL) { OPENSSL_free(a); diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index f77e59df37..08bbc3988b 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -67,7 +67,7 @@ X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) { X509_LOOKUP *ret; - ret = (X509_LOOKUP *)OPENSSL_malloc(sizeof(X509_LOOKUP)); + ret = OPENSSL_malloc(sizeof(X509_LOOKUP)); if (ret == NULL) return NULL; @@ -184,7 +184,7 @@ X509_STORE *X509_STORE_new(void) { X509_STORE *ret; - if ((ret = (X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL) + if ((ret = OPENSSL_malloc(sizeof(X509_STORE))) == NULL) return NULL; ret->objs = sk_X509_OBJECT_new(x509_object_cmp); ret->cache = 1; @@ -341,7 +341,7 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x) if (x == NULL) return 0; - obj = (X509_OBJECT *)OPENSSL_malloc(sizeof(X509_OBJECT)); + obj = OPENSSL_malloc(sizeof(X509_OBJECT)); if (obj == NULL) { X509err(X509_F_X509_STORE_ADD_CERT, ERR_R_MALLOC_FAILURE); return 0; @@ -374,7 +374,7 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x) if (x == NULL) return 0; - obj = (X509_OBJECT *)OPENSSL_malloc(sizeof(X509_OBJECT)); + obj = OPENSSL_malloc(sizeof(X509_OBJECT)); if (obj == NULL) { X509err(X509_F_X509_STORE_ADD_CRL, ERR_R_MALLOC_FAILURE); return 0; diff --git a/crypto/x509/x509_req.c b/crypto/x509/x509_req.c index 682c2c2acb..e01fc79d6e 100644 --- a/crypto/x509/x509_req.c +++ b/crypto/x509/x509_req.c @@ -83,7 +83,7 @@ X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) ri = ret->req_info; ri->version->length = 1; - ri->version->data = (unsigned char *)OPENSSL_malloc(1); + ri->version->data = OPENSSL_malloc(1); if (ri->version->data == NULL) goto err; ri->version->data[0] = 0; /* version == 0 */ diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 9cf39db269..85dc714f4e 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -2218,7 +2218,8 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, X509_STORE_CTX *X509_STORE_CTX_new(void) { X509_STORE_CTX *ctx; - ctx = (X509_STORE_CTX *)OPENSSL_malloc(sizeof(X509_STORE_CTX)); + + ctx = OPENSSL_malloc(sizeof(X509_STORE_CTX)); if (!ctx) { X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index 7e3e984cf6..3396ff1c76 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c @@ -140,9 +140,7 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from) X509V3_R_EXTENSION_NOT_FOUND); return 0; } - if (! - (tmpext = - (X509V3_EXT_METHOD *)OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) { + if (!(tmpext = OPENSSL_malloc(sizeof(X509V3_EXT_METHOD)))) { X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, ERR_R_MALLOC_FAILURE); return 0; } diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c index cd7a9809ca..aa3a4dea90 100644 --- a/crypto/x509v3/v3_utl.c +++ b/crypto/x509v3/v3_utl.c @@ -88,7 +88,7 @@ int X509V3_add_value(const char *name, const char *value, goto err; if (value && !(tvalue = BUF_strdup(value))) goto err; - if (!(vtmp = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) + if (!(vtmp = OPENSSL_malloc(sizeof(CONF_VALUE)))) goto err; if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null())) goto err; diff --git a/demos/b64.c b/demos/b64.c index fcc69562c1..2fa4e980ce 100644 --- a/demos/b64.c +++ b/demos/b64.c @@ -169,7 +169,7 @@ char **argv; } strbuf = OPENSSL_malloc(SIZE); - buff = (unsigned char *)OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize)); + buff = OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize)); if ((buff == NULL) || (strbuf == NULL)) { BIO_printf(bio_err, "OPENSSL_malloc failure\n"); goto end; diff --git a/engines/ccgost/gost_crypt.c b/engines/ccgost/gost_crypt.c index 6c95497a49..5f50fccbed 100644 --- a/engines/ccgost/gost_crypt.c +++ b/engines/ccgost/gost_crypt.c @@ -446,7 +446,7 @@ int gost89_set_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params) gcp->enc_param_set = OBJ_nid2obj(c->paramNID); len = i2d_GOST_CIPHER_PARAMS(gcp, NULL); - p = buf = (unsigned char *)OPENSSL_malloc(len); + p = buf = OPENSSL_malloc(len); if (!buf) { GOST_CIPHER_PARAMS_free(gcp); GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_MALLOC_FAILURE); diff --git a/engines/e_cswift.c b/engines/e_cswift.c index db94bf2a64..adab4d4188 100644 --- a/engines/e_cswift.c +++ b/engines/e_cswift.c @@ -586,7 +586,7 @@ int cswift_bn_32copy(SW_LARGENUMBER *out, const BIGNUM *in) while (((out->nbytes = (numbytes + mod)) % 32)) { mod++; } - out->value = (unsigned char *)OPENSSL_malloc(out->nbytes); + out->value = OPENSSL_malloc(out->nbytes); if (!out->value) { return 0; } diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c index 473b3ff519..da98ea03d8 100644 --- a/ssl/bio_ssl.c +++ b/ssl/bio_ssl.c @@ -103,7 +103,7 @@ static int ssl_new(BIO *bi) { BIO_SSL *bs; - bs = (BIO_SSL *)OPENSSL_malloc(sizeof(BIO_SSL)); + bs = OPENSSL_malloc(sizeof(BIO_SSL)); if (bs == NULL) { BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE); return (0); diff --git a/ssl/d1_both.c b/ssl/d1_both.c index c3552e9276..2a76474b98 100644 --- a/ssl/d1_both.c +++ b/ssl/d1_both.c @@ -170,12 +170,12 @@ static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len, unsigned char *buf = NULL; unsigned char *bitmask = NULL; - frag = (hm_fragment *)OPENSSL_malloc(sizeof(hm_fragment)); + frag = OPENSSL_malloc(sizeof(hm_fragment)); if (frag == NULL) return NULL; if (frag_len) { - buf = (unsigned char *)OPENSSL_malloc(frag_len); + buf = OPENSSL_malloc(frag_len); if (buf == NULL) { OPENSSL_free(frag); return NULL; @@ -187,8 +187,7 @@ static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len, /* Initialize reassembly bitmask if necessary */ if (reassembly) { - bitmask = - (unsigned char *)OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len)); + bitmask = OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len)); if (bitmask == NULL) { if (buf != NULL) OPENSSL_free(buf); diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index d6401b43d2..4daa29692b 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -184,7 +184,7 @@ CERT *ssl_cert_new(void) { CERT *ret; - ret = (CERT *)OPENSSL_malloc(sizeof(CERT)); + ret = OPENSSL_malloc(sizeof(CERT)); if (ret == NULL) { SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE); return (NULL); @@ -205,7 +205,7 @@ CERT *ssl_cert_dup(CERT *cert) CERT *ret; int i; - ret = (CERT *)OPENSSL_malloc(sizeof(CERT)); + ret = OPENSSL_malloc(sizeof(CERT)); if (ret == NULL) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 580098afa9..14decbc149 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -499,7 +499,7 @@ static void load_builtin_compressions(void) MemCheck_off(); ssl_comp_methods = sk_SSL_COMP_new(sk_comp_cmp); if (ssl_comp_methods != NULL) { - comp = (SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP)); + comp = OPENSSL_malloc(sizeof(SSL_COMP)); if (comp != NULL) { comp->method = COMP_zlib(); if (comp->method && comp->method->type == NID_undef) @@ -1452,8 +1452,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, STACK fprintf(stderr, "ssl_create_cipher_list() for %d ciphers\n", num_of_ciphers); #endif /* KSSL_DEBUG */ - co_list = - (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers); + co_list = OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers); if (co_list == NULL) { SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST, ERR_R_MALLOC_FAILURE); return (NULL); /* Failure */ @@ -1935,7 +1934,7 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm) } MemCheck_off(); - comp = (SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP)); + comp = OPENSSL_malloc(sizeof(SSL_COMP)); if (comp == NULL) { MemCheck_on(); SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD, ERR_R_MALLOC_FAILURE); diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 35a3c9d7b8..73eafdb542 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -276,7 +276,7 @@ SSL *SSL_new(SSL_CTX *ctx) return (NULL); } - s = (SSL *)OPENSSL_malloc(sizeof(SSL)); + s = OPENSSL_malloc(sizeof(SSL)); if (s == NULL) goto err; memset(s, 0, sizeof(SSL)); @@ -1868,7 +1868,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); goto err; } - ret = (SSL_CTX *)OPENSSL_malloc(sizeof(SSL_CTX)); + ret = OPENSSL_malloc(sizeof(SSL_CTX)); if (ret == NULL) goto err; diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 483c7787a2..51f30fbd3d 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -193,7 +193,7 @@ SSL_SESSION *SSL_SESSION_new(void) { SSL_SESSION *ss; - ss = (SSL_SESSION *)OPENSSL_malloc(sizeof(SSL_SESSION)); + ss = OPENSSL_malloc(sizeof(SSL_SESSION)); if (ss == NULL) { SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE); return (0); @@ -786,7 +786,7 @@ int SSL_set_session(SSL *s, SSL_SESSION *session) if (s->kssl_ctx && !s->kssl_ctx->client_princ && session->krb5_client_princ_len > 0) { s->kssl_ctx->client_princ = - (char *)OPENSSL_malloc(session->krb5_client_princ_len + 1); + OPENSSL_malloc(session->krb5_client_princ_len + 1); if (s->kssl_ctx->client_princ == NULL) { SSLerr(SSL_F_SSL_SET_SESSION, ERR_R_MALLOC_FAILURE); return (0); diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index 6e926d4bf7..1f58ed017b 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -649,7 +649,7 @@ int tls1_setup_key_block(SSL *s) ssl3_cleanup_key_block(s); - if ((p1 = (unsigned char *)OPENSSL_malloc(num)) == NULL) { + if ((p1 = OPENSSL_malloc(num)) == NULL) { SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE); goto err; } @@ -657,7 +657,7 @@ int tls1_setup_key_block(SSL *s) s->s3->tmp.key_block_length = num; s->s3->tmp.key_block = p1; - if ((p2 = (unsigned char *)OPENSSL_malloc(num)) == NULL) { + if ((p2 = OPENSSL_malloc(num)) == NULL) { SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE); OPENSSL_free(p1); goto err; diff --git a/test/dhtest.c b/test/dhtest.c index 6c063daf3d..35bd298a87 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) BIO_puts(out, "\n"); alen = DH_size(a); - abuf = (unsigned char *)OPENSSL_malloc(alen); + abuf = OPENSSL_malloc(alen); aout = DH_compute_key(abuf, b->pub_key, a); BIO_puts(out, "key1 ="); @@ -176,7 +176,7 @@ int main(int argc, char *argv[]) BIO_puts(out, "\n"); blen = DH_size(b); - bbuf = (unsigned char *)OPENSSL_malloc(blen); + bbuf = OPENSSL_malloc(blen); bout = DH_compute_key(bbuf, a->pub_key, b); BIO_puts(out, "key2 ="); diff --git a/test/ecdhtest.c b/test/ecdhtest.c index a89177e435..5c451e52be 100644 --- a/test/ecdhtest.c +++ b/test/ecdhtest.c @@ -201,7 +201,7 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) # endif alen = KDF1_SHA1_len; - abuf = (unsigned char *)OPENSSL_malloc(alen); + abuf = OPENSSL_malloc(alen); aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), a, KDF1_SHA1); @@ -218,7 +218,7 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) # endif blen = KDF1_SHA1_len; - bbuf = (unsigned char *)OPENSSL_malloc(blen); + bbuf = OPENSSL_malloc(blen); bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), b, KDF1_SHA1); -- 2.34.1