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>
This commit is contained in:
Rich Salz 2015-04-28 15:28:14 -04:00
parent 3e47caff48
commit b196e7d936
114 changed files with 191 additions and 226 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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];

View File

@ -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;

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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) {

View File

@ -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)

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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));

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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++)

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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]))

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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));

View File

@ -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;
}

View File

@ -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

View File

@ -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));

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More