Browse Source

Use safer sizeof variant in malloc

For a local variable:
        TYPE *p;
Allocations like this are "risky":
        p = OPENSSL_malloc(sizeof(TYPE));
if the type of p changes, and the malloc call isn't updated, you
could get memory corruption.  Instead do this:
        p = OPENSSL_malloc(sizeof(*p));
Also fixed a few memset() calls that I noticed while doing this.

Reviewed-by: Richard Levitte <levitte@openssl.org>
master
Rich Salz 7 years ago
committed by Rich Salz
parent
commit
b4faea50c3
142 changed files with 278 additions and 283 deletions
  1. +5
    -4
      apps/apps.c
  2. +2
    -2
      apps/ca.c
  3. +1
    -1
      apps/cms.c
  4. +1
    -1
      apps/ecparam.c
  5. +1
    -1
      apps/openssl.c
  6. +1
    -1
      apps/s_cb.c
  7. +3
    -3
      apps/s_server.c
  8. +1
    -1
      apps/speed.c
  9. +1
    -1
      apps/srp.c
  10. +1
    -1
      apps/vms_decc_init.c
  11. +2
    -2
      crypto/LPdir_unix.c
  12. +2
    -2
      crypto/LPdir_vms.c
  13. +2
    -2
      crypto/LPdir_win.c
  14. +1
    -1
      crypto/asn1/a_object.c
  15. +1
    -1
      crypto/asn1/a_strnid.c
  16. +1
    -1
      crypto/asn1/ameth_lib.c
  17. +1
    -1
      crypto/asn1/asn1_lib.c
  18. +2
    -2
      crypto/asn1/asn_mime.c
  19. +1
    -1
      crypto/asn1/bio_asn1.c
  20. +1
    -1
      crypto/asn1/bio_ndef.c
  21. +1
    -1
      crypto/asn1/tasn_new.c
  22. +1
    -1
      crypto/asn1/tasn_prn.c
  23. +1
    -1
      crypto/asn1/tasn_scn.c
  24. +1
    -1
      crypto/asn1/x_crl.c
  25. +1
    -1
      crypto/asn1/x_info.c
  26. +2
    -2
      crypto/asn1/x_pkey.c
  27. +1
    -2
      crypto/bio/bf_buff.c
  28. +1
    -1
      crypto/bio/bf_lbuf.c
  29. +1
    -1
      crypto/bio/bf_nbio.c
  30. +1
    -2
      crypto/bio/bio_lib.c
  31. +1
    -1
      crypto/bio/bss_acpt.c
  32. +1
    -1
      crypto/bio/bss_bio.c
  33. +1
    -1
      crypto/bio/bss_conn.c
  34. +2
    -2
      crypto/bio/bss_dgram.c
  35. +7
    -7
      crypto/bn/Makefile
  36. +1
    -1
      crypto/bn/bn_blind.c
  37. +2
    -2
      crypto/bn/bn_ctx.c
  38. +5
    -5
      crypto/bn/bn_gf2m.c
  39. +3
    -3
      crypto/bn/bn_lib.c
  40. +1
    -1
      crypto/bn/bn_mont.c
  41. +1
    -1
      crypto/bn/bn_recp.c
  42. +1
    -1
      crypto/buffer/buffer.c
  43. +2
    -1
      crypto/cmac/cmac.c
  44. +2
    -2
      crypto/comp/c_zlib.c
  45. +1
    -1
      crypto/comp/comp_lib.c
  46. +1
    -1
      crypto/conf/conf_api.c
  47. +2
    -2
      crypto/conf/conf_def.c
  48. +2
    -2
      crypto/conf/conf_mod.c
  49. +1
    -1
      crypto/dh/dh_lib.c
  50. +1
    -1
      crypto/dh/dh_pmeth.c
  51. +1
    -1
      crypto/dsa/dsa_asn1.c
  52. +1
    -1
      crypto/dsa/dsa_lib.c
  53. +1
    -1
      crypto/dsa/dsa_pmeth.c
  54. +1
    -1
      crypto/dso/dso_lib.c
  55. +1
    -1
      crypto/dso/dso_vms.c
  56. +2
    -2
      crypto/dso/dso_win32.c
  57. +6
    -5
      crypto/ec/Makefile
  58. +1
    -2
      crypto/ec/ec_key.c
  59. +5
    -5
      crypto/ec/ec_lib.c
  60. +4
    -4
      crypto/ec/ec_mult.c
  61. +2
    -1
      crypto/ec/ec_pmeth.c
  62. +2
    -2
      crypto/ec/ecp_nistp224.c
  63. +2
    -2
      crypto/ec/ecp_nistp256.c
  64. +2
    -2
      crypto/ec/ecp_nistp521.c
  65. +2
    -2
      crypto/ec/ecp_nistz256.c
  66. +1
    -1
      crypto/ecdh/ech_lib.c
  67. +2
    -2
      crypto/ecdsa/ecs_lib.c
  68. +2
    -2
      crypto/engine/eng_dyn.c
  69. +2
    -2
      crypto/engine/eng_lib.c
  70. +1
    -1
      crypto/engine/eng_openssl.c
  71. +1
    -1
      crypto/engine/eng_table.c
  72. +3
    -3
      crypto/err/err.c
  73. +1
    -1
      crypto/evp/bio_b64.c
  74. +1
    -1
      crypto/evp/bio_enc.c
  75. +1
    -1
      crypto/evp/bio_ok.c
  76. +4
    -4
      crypto/evp/digest.c
  77. +2
    -2
      crypto/evp/evp_enc.c
  78. +2
    -1
      crypto/evp/evp_pbe.c
  79. +1
    -1
      crypto/evp/p_lib.c
  80. +4
    -3
      crypto/evp/pmeth_lib.c
  81. +2
    -2
      crypto/ex_data.c
  82. +1
    -1
      crypto/hmac/hm_pmeth.c
  83. +1
    -1
      crypto/hmac/hmac.c
  84. +2
    -2
      crypto/jpake/jpake.c
  85. +3
    -3
      crypto/lhash/lhash.c
  86. +1
    -1
      crypto/lock.c
  87. +2
    -2
      crypto/mem_dbg.c
  88. +1
    -1
      crypto/modes/gcm128.c
  89. +1
    -1
      crypto/modes/ocb128.c
  90. +4
    -4
      crypto/objects/Makefile
  91. +4
    -4
      crypto/objects/o_names.c
  92. +4
    -7
      crypto/objects/obj_dat.c
  93. +1
    -1
      crypto/objects/obj_xref.c
  94. +2
    -2
      crypto/ocsp/ocsp_ht.c
  95. +2
    -2
      crypto/pqueue/pqueue.c
  96. +1
    -1
      crypto/rsa/rsa_lib.c
  97. +1
    -1
      crypto/rsa/rsa_pmeth.c
  98. +4
    -4
      crypto/srp/srp_vfy.c
  99. +2
    -2
      crypto/stack/stack.c
  100. +7
    -6
      crypto/store/str_lib.c

+ 5
- 4
apps/apps.c 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 = app_malloc(sizeof(char *) * arg->size, "argv space");
arg->argv = app_malloc(sizeof(*arg->argv) * arg->size, "argv space");
if (arg->argv == NULL)
return 0;
}
@ -195,7 +195,8 @@ int chopup_args(ARGS *arg, char *buf)
/* The start of something good :-) */
if (arg->argc >= arg->size) {
arg->size += 20;
arg->argv = OPENSSL_realloc(arg->argv, sizeof(char *) * arg->size);
arg->argv = OPENSSL_realloc(arg->argv,
sizeof(*arg->argv) * arg->size);
if (arg->argv == NULL)
return 0;
}
@ -1585,7 +1586,7 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
}
}
retdb = app_malloc(sizeof *retdb, "new DB");
retdb = app_malloc(sizeof(*retdb), "new DB");
retdb->db = tmpdb;
tmpdb = NULL;
if (db_attr)
@ -2364,7 +2365,7 @@ static int WIN32_rename(const char *from, const char *to)
} else { /* UNICODE path */
size_t i, flen = strlen(from) + 1, tlen = strlen(to) + 1;
tfrom = (TCHAR *)malloc(sizeof(TCHAR) * (flen + tlen));
tfrom = malloc(*sizeof(*tfrom) * (flen + tlen));
if (tfrom == NULL)
goto err;
tto = tfrom + flen;


+ 2
- 2
apps/ca.c View File

@ -1970,7 +1970,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
row[DB_type][0] = 'V';
row[DB_type][1] = '\0';
irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row space");
irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row space");
for (i = 0; i < DB_NUMBER; i++) {
irow[i] = row[i];
row[i] = NULL;
@ -2207,7 +2207,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
row[DB_type][0] = 'V';
row[DB_type][1] = '\0';
irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row ptr");
irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row ptr");
for (i = 0; i < DB_NUMBER; i++) {
irow[i] = row[i];
row[i] = NULL;


+ 1
- 1
apps/cms.c View File

@ -570,7 +570,7 @@ int cms_main(int argc, char **argv)
}
if (key_param == NULL || key_param->idx != keyidx) {
cms_key_param *nparam;
nparam = app_malloc(sizeof *nparam, "key param buffer");
nparam = app_malloc(sizeof(*nparam), "key param buffer");
nparam->idx = keyidx;
if ((nparam->param = sk_OPENSSL_STRING_new_null()) == NULL)
goto end;


+ 1
- 1
apps/ecparam.c View File

@ -232,7 +232,7 @@ int ecparam_main(int argc, char **argv)
size_t crv_len = EC_get_builtin_curves(NULL, 0);
size_t n;
curves = app_malloc((int)(sizeof *curves * crv_len), "list curves");
curves = app_malloc((int)sizeof(*curves) * crv_len, "list curves");
if (!EC_get_builtin_curves(curves, crv_len)) {
OPENSSL_free(curves);
goto end;


+ 1
- 1
apps/openssl.c View File

@ -804,7 +804,7 @@ static LHASH_OF(FUNCTION) *prog_init(void)
/* Sort alphabetically within category. For nicer help displays. */
for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
qsort(functions, i, sizeof *functions, SortFnByName);
qsort(functions, i, sizeof(*functions), SortFnByName);
if ((ret = lh_FUNCTION_new()) == NULL)
return (NULL);


+ 1
- 1
apps/s_cb.c View File

@ -1173,7 +1173,7 @@ void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc)
static int ssl_excert_prepend(SSL_EXCERT **pexc)
{
SSL_EXCERT *exc = app_malloc(sizeof *exc, "prepend cert");
SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");
exc->certfile = NULL;
exc->keyfile = NULL;


+ 3
- 3
apps/s_server.c View File

@ -461,7 +461,7 @@ static int ebcdic_new(BIO *bi)
{
EBCDIC_OUTBUFF *wbuf;
wbuf = app_malloc(sizeof(EBCDIC_OUTBUFF) + 1024, "ebcdef wbuf");
wbuf = app_malloc(sizeof(*wbuf) + 1024, "ebcdic wbuf");
wbuf->alloced = 1024;
wbuf->buff[0] = '\0';
@ -515,7 +515,7 @@ static int ebcdic_write(BIO *b, const char *in, int inl)
num = num + num; /* double the size */
if (num < inl)
num = inl;
wbuf = app_malloc(sizeof(EBCDIC_OUTBUFF) + num, "grow ebcdic wbuf");
wbuf = app_malloc(sizeof(*wbuf) + num, "grow ebcdic wbuf");
OPENSSL_free(b->ptr);
wbuf->alloced = num;
@ -3127,7 +3127,7 @@ static simple_ssl_session *first = NULL;
static int add_session(SSL *ssl, SSL_SESSION *session)
{
simple_ssl_session *sess = app_malloc(sizeof *sess, "get session");
simple_ssl_session *sess = app_malloc(sizeof(*sess), "get session");
unsigned char *p;
SSL_SESSION_get_id(session, &sess->idlen);


+ 1
- 1
apps/speed.c View File

@ -2283,7 +2283,7 @@ static int do_multi(int multi)
int *fds;
static char sep[] = ":";
fds = malloc(multi * sizeof *fds);
fds = malloc(sizeof(*fds) * multi);
for (n = 0; n < multi; ++n) {
if (pipe(fd) == -1) {
fprintf(stderr, "pipe failure\n");


+ 1
- 1
apps/srp.c View File

@ -138,7 +138,7 @@ static int update_index(CA_DB *db, char **row)
char **irow;
int i;
irow = app_malloc(sizeof(char *) * (DB_NUMBER + 1), "row pointers");
irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row pointers");
for (i = 0; i < DB_NUMBER; i++) {
irow[i] = row[i];
row[i] = NULL;


+ 1
- 1
apps/vms_decc_init.c View File

@ -130,7 +130,7 @@ char **copy_argv(int *argc, char *argv[])
*/
int i, count = *argc;
char **newargv = app_malloc((count + 1) * sizeof *newargv, "argv copy");
char **newargv = app_malloc(sizeof(*newargv) * (count + 1), "argv copy");
for (i = 0; i < count; i++)
newargv[i] = argv[i];


+ 2
- 2
crypto/LPdir_unix.c View File

@ -78,12 +78,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
errno = 0;
if (*ctx == NULL) {
*ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
*ctx = malloc(sizeof(**ctx));
if (*ctx == NULL) {
errno = ENOMEM;
return 0;
}
memset(*ctx, '\0', sizeof(LP_DIR_CTX));
memset(*ctx, '\0', sizeof(**ctx));
(*ctx)->dir = opendir(directory);
if ((*ctx)->dir == NULL) {


+ 2
- 2
crypto/LPdir_vms.c View File

@ -104,12 +104,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
return 0;
}
*ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
*ctx = malloc(sizeof(**ctx));
if (*ctx == NULL) {
errno = ENOMEM;
return 0;
}
memset(*ctx, '\0', sizeof(LP_DIR_CTX));
memset(*ctx, '\0', sizeof(**ctx));
strcpy((*ctx)->filespec, directory);
strcat((*ctx)->filespec, "*.*;");


+ 2
- 2
crypto/LPdir_win.c View File

@ -69,12 +69,12 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
return 0;
}
*ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
*ctx = malloc(sizeof(**ctx));
if (*ctx == NULL) {
errno = ENOMEM;
return 0;
}
memset(*ctx, '\0', sizeof(LP_DIR_CTX));
memset(*ctx, '\0', sizeof(**ctx));
if (directory[dirlen - 1] != '*') {
extdirbuf = (char *)malloc(dirlen + 3);


+ 1
- 1
crypto/asn1/a_object.c View File

@ -345,7 +345,7 @@ ASN1_OBJECT *ASN1_OBJECT_new(void)
{
ASN1_OBJECT *ret;
ret = OPENSSL_malloc(sizeof(ASN1_OBJECT));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 1
- 1
crypto/asn1/a_strnid.c View File

@ -240,7 +240,7 @@ static ASN1_STRING_TABLE *stable_get(int nid)
tmp = ASN1_STRING_TABLE_get(nid);
if (tmp && tmp->flags & STABLE_FLAGS_MALLOC)
return tmp;
rv = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
rv = OPENSSL_malloc(sizeof(*rv));
if (!rv)
return NULL;
if (!sk_ASN1_STRING_TABLE_push(stable, rv)) {


+ 1
- 1
crypto/asn1/ameth_lib.c View File

@ -284,7 +284,7 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
const char *pem_str, const char *info)
{
EVP_PKEY_ASN1_METHOD *ameth;
ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD));
ameth = OPENSSL_malloc(sizeof(*ameth));
if (!ameth)
return NULL;


+ 1
- 1
crypto/asn1/asn1_lib.c View File

@ -349,7 +349,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
{
ASN1_STRING *ret;
ret = OPENSSL_malloc(sizeof(ASN1_STRING));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 2
- 2
crypto/asn1/asn_mime.c View File

@ -844,7 +844,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
}
}
}
mhdr = OPENSSL_malloc(sizeof(MIME_HEADER));
mhdr = OPENSSL_malloc(sizeof(*mhdr));
if (!mhdr)
goto err;
mhdr->name = tmpname;
@ -883,7 +883,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 = OPENSSL_malloc(sizeof(MIME_PARAM));
mparam = OPENSSL_malloc(sizeof(*mparam));
if (!mparam)
goto err;
mparam->param_name = tmpname;


+ 1
- 1
crypto/asn1/bio_asn1.c View File

@ -146,7 +146,7 @@ BIO_METHOD *BIO_f_asn1(void)
static int asn1_bio_new(BIO *b)
{
BIO_ASN1_BUF_CTX *ctx;
ctx = OPENSSL_malloc(sizeof(BIO_ASN1_BUF_CTX));
ctx = OPENSSL_malloc(sizeof(*ctx));
if (!ctx)
return 0;
if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE)) {


+ 1
- 1
crypto/asn1/bio_ndef.c View File

@ -106,7 +106,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED);
return NULL;
}
ndef_aux = OPENSSL_malloc(sizeof(NDEF_SUPPORT));
ndef_aux = OPENSSL_malloc(sizeof(*ndef_aux));
asn_bio = BIO_new(BIO_f_asn1());
/* ASN1 bio needs to be next to output BIO */


+ 1
- 1
crypto/asn1/tasn_new.c View File

@ -319,7 +319,7 @@ static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
return 1;
case V_ASN1_ANY:
typ = OPENSSL_malloc(sizeof(ASN1_TYPE));
typ = OPENSSL_malloc(sizeof(*typ));
if (!typ)
return 0;
typ->value.ptr = NULL;


+ 1
- 1
crypto/asn1/tasn_prn.c View File

@ -85,7 +85,7 @@ ASN1_PCTX default_pctx = {
ASN1_PCTX *ASN1_PCTX_new(void)
{
ASN1_PCTX *ret;
ret = OPENSSL_malloc(sizeof(ASN1_PCTX));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;


+ 1
- 1
crypto/asn1/tasn_scn.c View File

@ -75,7 +75,7 @@
ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx))
{
ASN1_SCTX *ret;
ret = OPENSSL_malloc(sizeof(ASN1_SCTX));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ASN1err(ASN1_F_ASN1_SCTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;


+ 1
- 1
crypto/asn1/x_crl.c View File

@ -476,7 +476,7 @@ X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
EVP_PKEY *pk))
{
X509_CRL_METHOD *m;
m = OPENSSL_malloc(sizeof(X509_CRL_METHOD));
m = OPENSSL_malloc(sizeof(*m));
if (!m)
return NULL;
m->crl_init = crl_init;


+ 1
- 1
crypto/asn1/x_info.c View File

@ -66,7 +66,7 @@ X509_INFO *X509_INFO_new(void)
{
X509_INFO *ret = NULL;
ret = OPENSSL_malloc(sizeof(X509_INFO));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 2
- 2
crypto/asn1/x_pkey.c View File

@ -66,10 +66,10 @@ X509_PKEY *X509_PKEY_new(void)
{
X509_PKEY *ret = NULL;
ret = OPENSSL_malloc(sizeof(X509_PKEY));
ret = OPENSSL_malloc(sizeof(*ret));
if (!ret)
goto err;
memset(ret, 0, sizeof(X509_PKEY));
memset(ret, 0, sizeof(*ret));
ret->version = 0;
ret->enc_algor = X509_ALGOR_new();


+ 1
- 2
crypto/bio/bf_buff.c View File

@ -91,9 +91,8 @@ BIO_METHOD *BIO_f_buffer(void)
static int buffer_new(BIO *bi)
{
BIO_F_BUFFER_CTX *ctx;
BIO_F_BUFFER_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
ctx = OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
if (ctx == NULL)
return (0);
ctx->ibuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);


+ 1
- 1
crypto/bio/bf_lbuf.c View File

@ -104,7 +104,7 @@ static int linebuffer_new(BIO *bi)
{
BIO_LINEBUFFER_CTX *ctx;
ctx = OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
ctx = OPENSSL_malloc(sizeof(*ctx));
if (ctx == NULL)
return (0);
ctx->obuf = OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);


+ 1
- 1
crypto/bio/bf_nbio.c View File

@ -102,7 +102,7 @@ static int nbiof_new(BIO *bi)
{
NBIO_TEST *nt;
if (!(nt = OPENSSL_malloc(sizeof(NBIO_TEST))))
if (!(nt = OPENSSL_malloc(sizeof(*nt))))
return (0);
nt->lrn = -1;
nt->lwn = -1;


+ 1
- 2
crypto/bio/bio_lib.c View File

@ -65,9 +65,8 @@
BIO *BIO_new(BIO_METHOD *method)
{
BIO *ret = NULL;
BIO *ret = OPENSSL_malloc(sizeof(*ret));
ret = OPENSSL_malloc(sizeof(BIO));
if (ret == NULL) {
BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 1
- 1
crypto/bio/bss_acpt.c View File

@ -137,7 +137,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void)
{
BIO_ACCEPT *ret;
if ((ret = OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
return (NULL);
memset(ret, 0, sizeof(BIO_ACCEPT));


+ 1
- 1
crypto/bio/bss_bio.c View File

@ -144,7 +144,7 @@ static int bio_new(BIO *bio)
{
struct bio_bio_st *b;
b = OPENSSL_malloc(sizeof *b);
b = OPENSSL_malloc(sizeof(*b));
if (b == NULL)
return 0;


+ 1
- 1
crypto/bio/bss_conn.c View File

@ -286,7 +286,7 @@ BIO_CONNECT *BIO_CONNECT_new(void)
{
BIO_CONNECT *ret;
if ((ret = OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL)
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
return (NULL);
ret->state = BIO_CONN_S_BEFORE;
ret->param_hostname = NULL;


+ 2
- 2
crypto/bio/bss_dgram.c View File

@ -225,7 +225,7 @@ static int dgram_new(BIO *bi)
bi->init = 0;
bi->num = 0;
data = OPENSSL_malloc(sizeof(bio_dgram_data));
data = OPENSSL_malloc(sizeof(*data));
if (data == NULL)
return 0;
memset(data, 0x00, sizeof(bio_dgram_data));
@ -1085,7 +1085,7 @@ static int dgram_sctp_new(BIO *bi)
bi->init = 0;
bi->num = 0;
data = OPENSSL_malloc(sizeof(bio_dgram_sctp_data));
data = OPENSSL_malloc(sizeof(*data));
if (data == NULL)
return 0;
memset(data, 0x00, sizeof(bio_dgram_sctp_data));


+ 7
- 7
crypto/bn/Makefile View File

@ -215,7 +215,7 @@ bn_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
bn_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
bn_depr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
bn_depr.o: ../cryptlib.h ../include/internal/bn_int.h bn_depr.c bn_lcl.h
bn_dh.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
bn_dh.o: ../../e_os.h ../../include/openssl/bn.h ../../include/openssl/crypto.h
bn_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
bn_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
bn_dh.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
@ -391,12 +391,12 @@ bn_sqrt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
bn_sqrt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
bn_sqrt.o: ../../include/openssl/symhacks.h ../cryptlib.h
bn_sqrt.o: ../include/internal/bn_int.h bn_lcl.h bn_sqrt.c
bn_srp.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
bn_srp.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
bn_srp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
bn_srp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
bn_srp.o: ../../include/openssl/symhacks.h ../include/internal/bn_int.h
bn_srp.o: bn_lcl.h bn_srp.c
bn_srp.o: ../../e_os.h ../../include/openssl/bn.h
bn_srp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
bn_srp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
bn_srp.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
bn_srp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
bn_srp.o: ../include/internal/bn_int.h bn_lcl.h bn_srp.c
bn_word.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h


+ 1
- 1
crypto/bn/bn_blind.c 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 = OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) {
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}


+ 2
- 2
crypto/bn/bn_ctx.c View File

@ -186,7 +186,7 @@ static void ctxdbg(BN_CTX *ctx)
BN_CTX *BN_CTX_new(void)
{
BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
BN_CTX *ret = OPENSSL_malloc(sizeof(*ret));
if (!ret) {
BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
@ -353,7 +353,7 @@ static BIGNUM *BN_POOL_get(BN_POOL *p)
if (p->used == p->size) {
BIGNUM *bn;
unsigned int loop = 0;
BN_POOL_ITEM *item = OPENSSL_malloc(sizeof(BN_POOL_ITEM));
BN_POOL_ITEM *item = OPENSSL_malloc(sizeof(*item));
if (!item)
return NULL;
/* Initialise the structure */


+ 5
- 5
crypto/bn/bn_gf2m.c 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 = OPENSSL_malloc(sizeof(int) * max)) == NULL)
if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max) {
@ -609,7 +609,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 = OPENSSL_malloc(sizeof(int) * max)) == NULL)
if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max) {
@ -1025,7 +1025,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 = OPENSSL_malloc(sizeof(int) * max)) == NULL)
if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max) {
@ -1084,7 +1084,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 = OPENSSL_malloc(sizeof(int) * max)) == NULL)
if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max) {
@ -1214,7 +1214,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 = OPENSSL_malloc(sizeof(int) * max)) == NULL)
if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max) {


+ 3
- 3
crypto/bn/bn_lib.c View File

@ -268,7 +268,7 @@ BIGNUM *BN_new(void)
{
BIGNUM *ret;
if ((ret = OPENSSL_malloc(sizeof(BIGNUM))) == NULL) {
if ((ret = OPENSSL_malloc(sizeof(*ret))) == 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 = OPENSSL_malloc(sizeof(BN_ULONG) * words);
a = A = OPENSSL_malloc(sizeof(*a) * words);
if (A == NULL) {
BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
return (NULL);
@ -919,7 +919,7 @@ BN_GENCB *BN_GENCB_new(void)
{
BN_GENCB *ret;
if ((ret = OPENSSL_malloc(sizeof(BN_GENCB))) == NULL) {
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}


+ 1
- 1
crypto/bn/bn_mont.c View File

@ -314,7 +314,7 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
{
BN_MONT_CTX *ret;
if ((ret = OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL)
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
return (NULL);
BN_MONT_CTX_init(ret);


+ 1
- 1
crypto/bn/bn_recp.c View File

@ -71,7 +71,7 @@ BN_RECP_CTX *BN_RECP_CTX_new(void)
{
BN_RECP_CTX *ret;
if ((ret = OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL)
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
return (NULL);
BN_RECP_CTX_init(ret);


+ 1
- 1
crypto/buffer/buffer.c View File

@ -71,7 +71,7 @@ BUF_MEM *BUF_MEM_new(void)
{
BUF_MEM *ret;
ret = OPENSSL_malloc(sizeof(BUF_MEM));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
BUFerr(BUF_F_BUF_MEM_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 2
- 1
crypto/cmac/cmac.c View File

@ -90,7 +90,8 @@ static void make_kn(unsigned char *k1, const unsigned char *l, int bl)
CMAC_CTX *CMAC_CTX_new(void)
{
CMAC_CTX *ctx;
ctx = OPENSSL_malloc(sizeof(CMAC_CTX));
ctx = OPENSSL_malloc(sizeof(*ctx));
if (!ctx)
return NULL;
EVP_CIPHER_CTX_init(&ctx->cctx);


+ 2
- 2
crypto/comp/c_zlib.c View File

@ -119,7 +119,7 @@ static int zlib_stateful_ex_idx = -1;
static int zlib_stateful_init(COMP_CTX *ctx)
{
int err;
struct zlib_state *state = OPENSSL_malloc(sizeof(struct zlib_state));
struct zlib_state *state = OPENSSL_malloc(sizeof(*state));
if (state == NULL)
goto err;
@ -347,7 +347,7 @@ static int bio_zlib_new(BIO *bi)
return 0;
}
# endif
ctx = OPENSSL_malloc(sizeof(BIO_ZLIB_CTX));
ctx = OPENSSL_malloc(sizeof(*ctx));
if (!ctx) {
COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE);
return 0;


+ 1
- 1
crypto/comp/comp_lib.c View File

@ -8,7 +8,7 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
{
COMP_CTX *ret;
if ((ret = OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) {
if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
/* ZZZZZZZZZZZZZZZZ */
return (NULL);
}


+ 1
- 1
crypto/conf/conf_api.c View File

@ -255,7 +255,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
if ((sk = sk_CONF_VALUE_new_null()) == NULL)
goto err;
if ((v = OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL)
if ((v = OPENSSL_malloc(sizeof(*v))) == NULL)
goto err;
i = strlen(section) + 1;
if ((v->section = OPENSSL_malloc(i)) == NULL)


+ 2
- 2
crypto/conf/conf_def.c View File

@ -130,7 +130,7 @@ static CONF *def_create(CONF_METHOD *meth)
{
CONF *ret;
ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret)
if (meth->init(ret) == 0) {
OPENSSL_free(ret);
@ -357,7 +357,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
p++;
*p = '\0';
if (!(v = OPENSSL_malloc(sizeof(CONF_VALUE)))) {
if (!(v = OPENSSL_malloc(sizeof(*v)))) {
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
}


+ 2
- 2
crypto/conf/conf_mod.c View File

@ -281,7 +281,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
supported_modules = sk_CONF_MODULE_new_null();
if (supported_modules == NULL)
return NULL;
tmod = OPENSSL_malloc(sizeof(CONF_MODULE));
tmod = OPENSSL_malloc(sizeof(*tmod));
if (tmod == NULL)
return NULL;
@ -336,7 +336,7 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
CONF_IMODULE *imod = NULL;
/* Otherwise add initialized module to list */
imod = OPENSSL_malloc(sizeof(CONF_IMODULE));
imod = OPENSSL_malloc(sizeof(*imod));
if (!imod)
goto err;


+ 1
- 1
crypto/dh/dh_lib.c View File

@ -109,7 +109,7 @@ DH *DH_new(void)
DH *DH_new_method(ENGINE *engine)
{
DH *ret = OPENSSL_malloc(sizeof(DH));
DH *ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);


+ 1
- 1
crypto/dh/dh_pmeth.c View File

@ -98,7 +98,7 @@ typedef struct {
static int pkey_dh_init(EVP_PKEY_CTX *ctx)
{
DH_PKEY_CTX *dctx;
dctx = OPENSSL_malloc(sizeof(DH_PKEY_CTX));
dctx = OPENSSL_malloc(sizeof(*dctx));
if (!dctx)
return 0;
dctx->prime_len = 1024;


+ 1
- 1
crypto/dsa/dsa_asn1.c View File

@ -70,7 +70,7 @@ static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
{
if (operation == ASN1_OP_NEW_PRE) {
DSA_SIG *sig;
sig = OPENSSL_malloc(sizeof(DSA_SIG));
sig = OPENSSL_malloc(sizeof(*sig));
if (!sig) {
DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE);
return 0;


+ 1
- 1
crypto/dsa/dsa_lib.c View File

@ -117,7 +117,7 @@ DSA *DSA_new_method(ENGINE *engine)
{
DSA *ret;
ret = OPENSSL_malloc(sizeof(DSA));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 1
- 1
crypto/dsa/dsa_pmeth.c View File

@ -81,7 +81,7 @@ typedef struct {
static int pkey_dsa_init(EVP_PKEY_CTX *ctx)
{
DSA_PKEY_CTX *dctx;
dctx = OPENSSL_malloc(sizeof(DSA_PKEY_CTX));
dctx = OPENSSL_malloc(sizeof(*dctx));
if (!dctx)
return 0;
dctx->nbits = 1024;


+ 1
- 1
crypto/dso/dso_lib.c View File

@ -104,7 +104,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
*/
default_DSO_meth = DSO_METHOD_openssl();
}
ret = OPENSSL_malloc(sizeof(DSO));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 1
- 1
crypto/dso/dso_vms.c View File

@ -230,7 +230,7 @@ static int vms_load(DSO *dso)
goto err;
}
p = DSO_MALLOC(sizeof(DSO_VMS_INTERNAL));
p = DSO_MALLOC(sizeof(*p));
if (p == NULL) {
DSOerr(DSO_F_VMS_LOAD, ERR_R_MALLOC_FAILURE);
goto err;


+ 2
- 2
crypto/dso/dso_win32.c View File

@ -168,7 +168,7 @@ static int win32_load(DSO *dso)
ERR_add_error_data(3, "filename(", filename, ")");
goto err;
}
p = OPENSSL_malloc(sizeof(HINSTANCE));
p = OPENSSL_malloc(sizeof(*p));
if (p == NULL) {
DSOerr(DSO_F_WIN32_LOAD, ERR_R_MALLOC_FAILURE);
goto err;
@ -304,7 +304,7 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename,
return (NULL);
}
result = OPENSSL_malloc(sizeof(struct file_st));
result = OPENSSL_malloc(sizeof(*result));
if (result == NULL) {
DSOerr(DSO_F_WIN32_SPLITTER, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 6
- 5
crypto/ec/Makefile View File

@ -143,11 +143,12 @@ ec_check.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h
ec_check.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
ec_check.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
ec_check.o: ../../include/openssl/symhacks.h ec_check.c ec_lcl.h
ec_curve.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
ec_curve.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
ec_curve.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
ec_curve.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
ec_curve.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h
ec_curve.o: ../../e_os.h ../../include/openssl/asn1.h
ec_curve.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
ec_curve.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
ec_curve.o: ../../include/openssl/ec.h ../../include/openssl/err.h
ec_curve.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
ec_curve.o: ../../include/openssl/opensslconf.h
ec_curve.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
ec_curve.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
ec_curve.o: ../../include/openssl/symhacks.h ec_curve.c ec_lcl.h


+ 1
- 2
crypto/ec/ec_key.c View File

@ -67,9 +67,8 @@
EC_KEY *EC_KEY_new(void)
{
EC_KEY *ret;
EC_KEY *ret = OPENSSL_malloc(sizeof(*ret));
ret = OPENSSL_malloc(sizeof(EC_KEY));
if (ret == NULL) {
ECerr(EC_F_EC_KEY_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 5
- 5
crypto/ec/ec_lib.c View File

@ -85,7 +85,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
return NULL;
}
ret = OPENSSL_malloc(sizeof *ret);
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ECerr(EC_F_EC_GROUP_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
@ -158,7 +158,7 @@ void EC_GROUP_clear_free(EC_GROUP *group)
BN_clear_free(group->order);
BN_clear_free(group->cofactor);
OPENSSL_clear_free(group->seed, group->seed_len);
OPENSSL_clear_free(group, sizeof *group);
OPENSSL_clear_free(group, sizeof(*group));
}
int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
@ -555,7 +555,7 @@ int EC_EX_DATA_set_data(EC_EXTRA_DATA **ex_data, void *data,
/* no explicit entry needed */
return 1;
d = OPENSSL_malloc(sizeof *d);
d = OPENSSL_malloc(sizeof(*d));
if (d == NULL)
return 0;
@ -692,7 +692,7 @@ EC_POINT *EC_POINT_new(const EC_GROUP *group)
return NULL;
}
ret = OPENSSL_malloc(sizeof *ret);
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ECerr(EC_F_EC_POINT_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
@ -727,7 +727,7 @@ void EC_POINT_clear_free(EC_POINT *point)
point->meth->point_clear_finish(point);
else if (point->meth->point_finish != 0)
point->meth->point_finish(point);
OPENSSL_clear_free(point, sizeof *point);
OPENSSL_clear_free(point, sizeof(*point));
}
int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)


+ 4
- 4
crypto/ec/ec_mult.c View File

@ -100,7 +100,7 @@ static EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group)
if (!group)
return NULL;
ret = OPENSSL_malloc(sizeof(EC_PRE_COMP));
ret = OPENSSL_malloc(sizeof(*ret));
if (!ret) {
ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
@ -165,11 +165,11 @@ static void ec_pre_comp_clear_free(void *pre_)
for (p = pre->points; *p != NULL; p++) {
EC_POINT_clear_free(*p);
OPENSSL_cleanse(p, sizeof *p);
OPENSSL_cleanse(p, sizeof(*p));
}
OPENSSL_free(pre->points);
}
OPENSSL_clear_free(pre, sizeof *pre);
OPENSSL_clear_free(pre, sizeof(*pre));
}
/*
@ -659,7 +659,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
num = pre_points_per_block * numblocks; /* number of points to compute
* and store */
points = OPENSSL_malloc(sizeof(EC_POINT *) * (num + 1));
points = OPENSSL_malloc(sizeof(*points) * (num + 1));
if (!points) {
ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);
goto err;


+ 2
- 1
crypto/ec/ec_pmeth.c View File

@ -91,7 +91,8 @@ typedef struct {
static int pkey_ec_init(EVP_PKEY_CTX *ctx)
{
EC_PKEY_CTX *dctx;
dctx = OPENSSL_malloc(sizeof(EC_PKEY_CTX));
dctx = OPENSSL_malloc(sizeof(*dctx));
if (!dctx)
return 0;
dctx->gen_group = NULL;


+ 2
- 2
crypto/ec/ecp_nistp224.c 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 = OPENSSL_malloc(sizeof *ret);
ret = OPENSSL_malloc(sizeof(*ret));
if (!ret) {
ECerr(EC_F_NISTP224_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
@ -1247,7 +1247,7 @@ static void nistp224_pre_comp_clear_free(void *pre_)
if (i > 0)
return;
OPENSSL_clear_free(pre, sizeof *pre);
OPENSSL_clear_free(pre, sizeof(*pre));
}
/******************************************************************************/


+ 2
- 2
crypto/ec/ecp_nistp256.c 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 = OPENSSL_malloc(sizeof *ret);
ret = OPENSSL_malloc(sizeof(*ret));
if (!ret) {
ECerr(EC_F_NISTP256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
@ -1862,7 +1862,7 @@ static void nistp256_pre_comp_clear_free(void *pre_)
if (i > 0)
return;
OPENSSL_clear_free(pre, sizeof *pre);
OPENSSL_clear_free(pre, sizeof(*pre));
}
/******************************************************************************/


+ 2
- 2
crypto/ec/ecp_nistp521.c View File

@ -1643,8 +1643,8 @@ const EC_METHOD *EC_GFp_nistp521_method(void)
static NISTP521_PRE_COMP *nistp521_pre_comp_new()
{
NISTP521_PRE_COMP *ret = NULL;
ret = OPENSSL_malloc(sizeof(NISTP521_PRE_COMP));
NISTP521_PRE_COMP *ret = OPENSSL_malloc(sizeof(*ret));
if (!ret) {
ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;


+ 2
- 2
crypto/ec/ecp_nistz256.c View File

@ -1408,7 +1408,7 @@ static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group)
if (!group)
return NULL;
ret = OPENSSL_malloc(sizeof(EC_PRE_COMP));
ret = OPENSSL_malloc(sizeof(*ret));
if (!ret) {
ECerr(EC_F_ECP_NISTZ256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
@ -1463,7 +1463,7 @@ static void ecp_nistz256_pre_comp_clear_free(void *pre_)
OPENSSL_clear_free(pre->precomp,
32 * sizeof(unsigned char) * (1 << pre->w) * 2 * 37);
OPENSSL_clear_free(pre, sizeof *pre);
OPENSSL_clear_free(pre, sizeof(*pre));
}
static int ecp_nistz256_window_have_precompute_mult(const EC_GROUP *group)


+ 1
- 1
crypto/ecdh/ech_lib.c View File

@ -117,7 +117,7 @@ static ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine)
{
ECDH_DATA *ret;
ret = OPENSSL_malloc(sizeof(ECDH_DATA));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
return (NULL);


+ 2
- 2
crypto/ecdsa/ecs_lib.c View File

@ -105,7 +105,7 @@ static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine)
{
ECDSA_DATA *ret;
ret = OPENSSL_malloc(sizeof(ECDSA_DATA));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
return (NULL);
@ -253,7 +253,7 @@ ECDSA_METHOD *ECDSA_METHOD_new(ECDSA_METHOD *ecdsa_meth)
{
ECDSA_METHOD *ret;
ret = OPENSSL_malloc(sizeof(ECDSA_METHOD));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ECDSAerr(ECDSA_F_ECDSA_METHOD_NEW, ERR_R_MALLOC_FAILURE);
return NULL;


+ 2
- 2
crypto/engine/eng_dyn.c View File

@ -202,8 +202,8 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
*/
static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
{
dynamic_data_ctx *c;
c = OPENSSL_malloc(sizeof(dynamic_data_ctx));
dynamic_data_ctx *c = OPENSSL_malloc(sizeof(*c));
if (!c) {
ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE);
return 0;


+ 2
- 2
crypto/engine/eng_lib.c View File

@ -66,7 +66,7 @@ ENGINE *ENGINE_new(void)
{
ENGINE *ret;
ret = OPENSSL_malloc(sizeof(ENGINE));
ret = OPENSSL_malloc(sizeof(*ret));
if (ret == NULL) {
ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
@ -163,7 +163,7 @@ static int int_cleanup_check(int create)
static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
{
ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(ENGINE_CLEANUP_ITEM));
ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));
if (!item)
return NULL;
item->cb = cb;


+ 1
- 1
crypto/engine/eng_openssl.c View File

@ -425,7 +425,7 @@ typedef struct {
static int ossl_hmac_init(EVP_PKEY_CTX *ctx)
{
OSSL_HMAC_PKEY_CTX *hctx;
hctx = OPENSSL_malloc(sizeof(OSSL_HMAC_PKEY_CTX));
hctx = OPENSSL_malloc(sizeof(*hctx));
if (!hctx)
return 0;
hctx->md = NULL;


+ 1
- 1
crypto/engine/eng_table.c View File

@ -147,7 +147,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
tmplate.nid = *nids;
fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
if (!fnd) {
fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
fnd = OPENSSL_malloc(sizeof(*fnd));
if (!fnd)
goto end;
fnd->uptodate = 1;


+ 3
- 3
crypto/err/err.c View File

@ -455,8 +455,8 @@ static void build_SYS_str_reasons(void)
char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
char *src = strerror(i);
if (src != NULL) {
strncpy(*dest, src, sizeof *dest);