summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcrypto/bn/bn_blind.c3
-rw-r--r--lib/libcrypto/comp/comp_lib.c3
-rw-r--r--lib/libcrypto/ec/ecp_nistp224.c6
-rw-r--r--lib/libcrypto/ec/ecp_nistp256.c6
-rw-r--r--lib/libcrypto/ec/ecp_nistp521.c6
-rw-r--r--lib/libcrypto/evp/pmeth_lib.c4
-rw-r--r--lib/libcrypto/pkcs7/bio_ber.c4
-rw-r--r--lib/libcrypto/store/str_meth.c6
-rw-r--r--lib/libcrypto/ts/ts_rsp_sign.c3
-rw-r--r--lib/libcrypto/ts/ts_verify_ctx.c7
-rw-r--r--lib/libcrypto/ui/ui_lib.c7
-rw-r--r--lib/libcrypto/x509/x509_vfy.c3
-rw-r--r--lib/libcrypto/x509/x509_vpm.c3
13 files changed, 21 insertions, 40 deletions
diff --git a/lib/libcrypto/bn/bn_blind.c b/lib/libcrypto/bn/bn_blind.c
index 7cced4f67f3..bc4027fe132 100644
--- a/lib/libcrypto/bn/bn_blind.c
+++ b/lib/libcrypto/bn/bn_blind.c
@@ -139,11 +139,10 @@ BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
bn_check_top(mod);
- if ((ret = (BN_BLINDING *)malloc(sizeof(BN_BLINDING))) == NULL) {
+ if ((ret = calloc(1, sizeof(BN_BLINDING))) == NULL) {
BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- memset(ret, 0, sizeof(BN_BLINDING));
if (A != NULL) {
if ((ret->A = BN_dup(A)) == NULL)
goto err;
diff --git a/lib/libcrypto/comp/comp_lib.c b/lib/libcrypto/comp/comp_lib.c
index 745c8022281..64d19df6635 100644
--- a/lib/libcrypto/comp/comp_lib.c
+++ b/lib/libcrypto/comp/comp_lib.c
@@ -9,11 +9,10 @@ COMP_CTX_new(COMP_METHOD *meth)
{
COMP_CTX *ret;
- if ((ret = (COMP_CTX *)malloc(sizeof(COMP_CTX))) == NULL) {
+ if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) {
/* ZZZZZZZZZZZZZZZZ */
return (NULL);
}
- memset(ret, 0, sizeof(COMP_CTX));
ret->meth = meth;
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
free(ret);
diff --git a/lib/libcrypto/ec/ecp_nistp224.c b/lib/libcrypto/ec/ecp_nistp224.c
index bd8f65b0973..53aced54d54 100644
--- a/lib/libcrypto/ec/ecp_nistp224.c
+++ b/lib/libcrypto/ec/ecp_nistp224.c
@@ -1435,8 +1435,8 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r,
*/
mixed = 1;
}
- secrets = malloc(num_points * sizeof(felem_bytearray));
- pre_comp = malloc(num_points * 17 * 3 * sizeof(felem));
+ secrets = calloc(num_points, sizeof(felem_bytearray));
+ pre_comp = calloc(num_points, 17 * 3 * sizeof(felem));
if (mixed)
tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem));
if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) {
@@ -1448,8 +1448,6 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r,
* infinity, i.e., they contribute nothing to the linear
* combination
*/
- memset(secrets, 0, num_points * sizeof(felem_bytearray));
- memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem));
for (i = 0; i < num_points; ++i) {
if (i == num)
/* the generator */
diff --git a/lib/libcrypto/ec/ecp_nistp256.c b/lib/libcrypto/ec/ecp_nistp256.c
index 558c29c5ba2..df80cc2b8ab 100644
--- a/lib/libcrypto/ec/ecp_nistp256.c
+++ b/lib/libcrypto/ec/ecp_nistp256.c
@@ -1985,8 +1985,8 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r,
*/
mixed = 1;
}
- secrets = malloc(num_points * sizeof(felem_bytearray));
- pre_comp = malloc(num_points * 17 * 3 * sizeof(smallfelem));
+ secrets = calloc(num_points, sizeof(felem_bytearray));
+ pre_comp = calloc(num_points, 17 * 3 * sizeof(smallfelem));
if (mixed)
tmp_smallfelems = malloc((num_points * 17 + 1) * sizeof(smallfelem));
if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_smallfelems == NULL))) {
@@ -1998,8 +1998,6 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r,
* infinity, i.e., they contribute nothing to the linear
* combination
*/
- memset(secrets, 0, num_points * sizeof(felem_bytearray));
- memset(pre_comp, 0, num_points * 17 * 3 * sizeof(smallfelem));
for (i = 0; i < num_points; ++i) {
if (i == num)
/*
diff --git a/lib/libcrypto/ec/ecp_nistp521.c b/lib/libcrypto/ec/ecp_nistp521.c
index 0c40f083462..6792c5b71d8 100644
--- a/lib/libcrypto/ec/ecp_nistp521.c
+++ b/lib/libcrypto/ec/ecp_nistp521.c
@@ -1872,8 +1872,8 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r,
*/
mixed = 1;
}
- secrets = malloc(num_points * sizeof(felem_bytearray));
- pre_comp = malloc(num_points * 17 * 3 * sizeof(felem));
+ secrets = calloc(num_points, sizeof(felem_bytearray));
+ pre_comp = calloc(num_points, 17 * 3 * sizeof(felem));
if (mixed)
tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem));
if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) {
@@ -1885,8 +1885,6 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r,
* infinity, i.e., they contribute nothing to the linear
* combination
*/
- memset(secrets, 0, num_points * sizeof(felem_bytearray));
- memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem));
for (i = 0; i < num_points; ++i) {
if (i == num)
/*
diff --git a/lib/libcrypto/evp/pmeth_lib.c b/lib/libcrypto/evp/pmeth_lib.c
index e51ae510981..82c3f875f31 100644
--- a/lib/libcrypto/evp/pmeth_lib.c
+++ b/lib/libcrypto/evp/pmeth_lib.c
@@ -196,12 +196,10 @@ EVP_PKEY_meth_new(int id, int flags)
{
EVP_PKEY_METHOD *pmeth;
- pmeth = malloc(sizeof(EVP_PKEY_METHOD));
+ pmeth = calloc(1, sizeof(EVP_PKEY_METHOD));
if (!pmeth)
return NULL;
- memset(pmeth, 0, sizeof(EVP_PKEY_METHOD));
-
pmeth->pkey_id = id;
pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC;
diff --git a/lib/libcrypto/pkcs7/bio_ber.c b/lib/libcrypto/pkcs7/bio_ber.c
index 216d237b4d8..fbcbd16abe6 100644
--- a/lib/libcrypto/pkcs7/bio_ber.c
+++ b/lib/libcrypto/pkcs7/bio_ber.c
@@ -126,11 +126,9 @@ static int ber_new(BIO *bi)
{
BIO_BER_CTX *ctx;
- ctx=(BIO_BER_CTX *)malloc(sizeof(BIO_BER_CTX));
+ ctx=calloc(1, sizeof(BIO_BER_CTX));
if (ctx == NULL) return(0);
- memset((char *)ctx,0,sizeof(BIO_BER_CTX));
-
bi->init=0;
bi->ptr=(char *)ctx;
bi->flags=0;
diff --git a/lib/libcrypto/store/str_meth.c b/lib/libcrypto/store/str_meth.c
index 8944824618e..0401aaa129b 100644
--- a/lib/libcrypto/store/str_meth.c
+++ b/lib/libcrypto/store/str_meth.c
@@ -62,13 +62,11 @@
STORE_METHOD *STORE_create_method(char *name)
{
- STORE_METHOD *store_method = (STORE_METHOD *)malloc(sizeof(STORE_METHOD));
+ STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD));
if (store_method)
- {
- memset(store_method, 0, sizeof(*store_method));
store_method->name = BUF_strdup(name);
- }
+
return store_method;
}
diff --git a/lib/libcrypto/ts/ts_rsp_sign.c b/lib/libcrypto/ts/ts_rsp_sign.c
index 0e57105858e..a81d4eedf02 100644
--- a/lib/libcrypto/ts/ts_rsp_sign.c
+++ b/lib/libcrypto/ts/ts_rsp_sign.c
@@ -145,11 +145,10 @@ TS_RESP_CTX_new(void)
{
TS_RESP_CTX *ctx;
- if (!(ctx = (TS_RESP_CTX *) malloc(sizeof(TS_RESP_CTX)))) {
+ if (!(ctx = calloc(1, sizeof(TS_RESP_CTX)))) {
TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
- memset(ctx, 0, sizeof(TS_RESP_CTX));
/* Setting default callbacks. */
ctx->serial_cb = def_serial_cb;
diff --git a/lib/libcrypto/ts/ts_verify_ctx.c b/lib/libcrypto/ts/ts_verify_ctx.c
index 3fc772678cc..e0803e9af92 100644
--- a/lib/libcrypto/ts/ts_verify_ctx.c
+++ b/lib/libcrypto/ts/ts_verify_ctx.c
@@ -63,12 +63,11 @@
TS_VERIFY_CTX *
TS_VERIFY_CTX_new(void)
{
- TS_VERIFY_CTX *ctx = (TS_VERIFY_CTX *) malloc(sizeof(TS_VERIFY_CTX));
+ TS_VERIFY_CTX *ctx = calloc(1, sizeof(TS_VERIFY_CTX));
- if (ctx)
- memset(ctx, 0, sizeof(TS_VERIFY_CTX));
- else
+ if (!ctx)
TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
+
return ctx;
}
diff --git a/lib/libcrypto/ui/ui_lib.c b/lib/libcrypto/ui/ui_lib.c
index db0ef98b721..ff548f4bb8d 100644
--- a/lib/libcrypto/ui/ui_lib.c
+++ b/lib/libcrypto/ui/ui_lib.c
@@ -584,12 +584,11 @@ UI_set_method(UI *ui, const UI_METHOD *meth)
UI_METHOD *
UI_create_method(char *name)
{
- UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD));
+ UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD));
- if (ui_method) {
- memset(ui_method, 0, sizeof(*ui_method));
+ if (ui_method)
ui_method->name = BUF_strdup(name);
- }
+
return ui_method;
}
diff --git a/lib/libcrypto/x509/x509_vfy.c b/lib/libcrypto/x509/x509_vfy.c
index 0024904c20b..7da415f27c5 100644
--- a/lib/libcrypto/x509/x509_vfy.c
+++ b/lib/libcrypto/x509/x509_vfy.c
@@ -1950,12 +1950,11 @@ X509_STORE_CTX_new(void)
{
X509_STORE_CTX *ctx;
- ctx = (X509_STORE_CTX *)malloc(sizeof(X509_STORE_CTX));
+ ctx = calloc(1, sizeof(X509_STORE_CTX));
if (!ctx) {
X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
- memset(ctx, 0, sizeof(X509_STORE_CTX));
return ctx;
}
diff --git a/lib/libcrypto/x509/x509_vpm.c b/lib/libcrypto/x509/x509_vpm.c
index f0d2a0902ef..c2cebd936fc 100644
--- a/lib/libcrypto/x509/x509_vpm.c
+++ b/lib/libcrypto/x509/x509_vpm.c
@@ -90,8 +90,7 @@ X509_VERIFY_PARAM_new(void)
{
X509_VERIFY_PARAM *param;
- param = malloc(sizeof(X509_VERIFY_PARAM));
- memset(param, 0, sizeof(X509_VERIFY_PARAM));
+ param = calloc(1, sizeof(X509_VERIFY_PARAM));
x509_verify_param_zero(param);
return param;
}