diff options
author | tedu <> | 2014-05-25 20:28:50 +0000 |
---|---|---|
committer | tedu <> | 2014-05-25 20:28:50 +0000 |
commit | 896ee758458e7d17dd2014f065480b5085e6be10 (patch) | |
tree | 7a0bda660a181d082657a078f67d9146fbd212c2 | |
parent | 339be6db68ff6f687a26e3c86aae9664fb3d0187 (diff) | |
download | openbsd-896ee758458e7d17dd2014f065480b5085e6be10.tar.gz openbsd-896ee758458e7d17dd2014f065480b5085e6be10.tar.bz2 openbsd-896ee758458e7d17dd2014f065480b5085e6be10.zip |
calloc instead of malloc/memset. from Benjamin Baier
26 files changed, 42 insertions, 80 deletions
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c index 7cced4f67f..bc4027fe13 100644 --- a/src/lib/libcrypto/bn/bn_blind.c +++ b/src/lib/libcrypto/bn/bn_blind.c | |||
@@ -139,11 +139,10 @@ BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) | |||
139 | 139 | ||
140 | bn_check_top(mod); | 140 | bn_check_top(mod); |
141 | 141 | ||
142 | if ((ret = (BN_BLINDING *)malloc(sizeof(BN_BLINDING))) == NULL) { | 142 | if ((ret = calloc(1, sizeof(BN_BLINDING))) == NULL) { |
143 | BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE); | 143 | BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE); |
144 | return (NULL); | 144 | return (NULL); |
145 | } | 145 | } |
146 | memset(ret, 0, sizeof(BN_BLINDING)); | ||
147 | if (A != NULL) { | 146 | if (A != NULL) { |
148 | if ((ret->A = BN_dup(A)) == NULL) | 147 | if ((ret->A = BN_dup(A)) == NULL) |
149 | goto err; | 148 | goto err; |
diff --git a/src/lib/libcrypto/comp/comp_lib.c b/src/lib/libcrypto/comp/comp_lib.c index 745c802228..64d19df663 100644 --- a/src/lib/libcrypto/comp/comp_lib.c +++ b/src/lib/libcrypto/comp/comp_lib.c | |||
@@ -9,11 +9,10 @@ COMP_CTX_new(COMP_METHOD *meth) | |||
9 | { | 9 | { |
10 | COMP_CTX *ret; | 10 | COMP_CTX *ret; |
11 | 11 | ||
12 | if ((ret = (COMP_CTX *)malloc(sizeof(COMP_CTX))) == NULL) { | 12 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { |
13 | /* ZZZZZZZZZZZZZZZZ */ | 13 | /* ZZZZZZZZZZZZZZZZ */ |
14 | return (NULL); | 14 | return (NULL); |
15 | } | 15 | } |
16 | memset(ret, 0, sizeof(COMP_CTX)); | ||
17 | ret->meth = meth; | 16 | ret->meth = meth; |
18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { | 17 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { |
19 | free(ret); | 18 | free(ret); |
diff --git a/src/lib/libcrypto/ec/ecp_nistp224.c b/src/lib/libcrypto/ec/ecp_nistp224.c index bd8f65b097..53aced54d5 100644 --- a/src/lib/libcrypto/ec/ecp_nistp224.c +++ b/src/lib/libcrypto/ec/ecp_nistp224.c | |||
@@ -1435,8 +1435,8 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, | |||
1435 | */ | 1435 | */ |
1436 | mixed = 1; | 1436 | mixed = 1; |
1437 | } | 1437 | } |
1438 | secrets = malloc(num_points * sizeof(felem_bytearray)); | 1438 | secrets = calloc(num_points, sizeof(felem_bytearray)); |
1439 | pre_comp = malloc(num_points * 17 * 3 * sizeof(felem)); | 1439 | pre_comp = calloc(num_points, 17 * 3 * sizeof(felem)); |
1440 | if (mixed) | 1440 | if (mixed) |
1441 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); | 1441 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); |
1442 | if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) { | 1442 | 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, | |||
1448 | * infinity, i.e., they contribute nothing to the linear | 1448 | * infinity, i.e., they contribute nothing to the linear |
1449 | * combination | 1449 | * combination |
1450 | */ | 1450 | */ |
1451 | memset(secrets, 0, num_points * sizeof(felem_bytearray)); | ||
1452 | memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem)); | ||
1453 | for (i = 0; i < num_points; ++i) { | 1451 | for (i = 0; i < num_points; ++i) { |
1454 | if (i == num) | 1452 | if (i == num) |
1455 | /* the generator */ | 1453 | /* the generator */ |
diff --git a/src/lib/libcrypto/ec/ecp_nistp256.c b/src/lib/libcrypto/ec/ecp_nistp256.c index 558c29c5ba..df80cc2b8a 100644 --- a/src/lib/libcrypto/ec/ecp_nistp256.c +++ b/src/lib/libcrypto/ec/ecp_nistp256.c | |||
@@ -1985,8 +1985,8 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, | |||
1985 | */ | 1985 | */ |
1986 | mixed = 1; | 1986 | mixed = 1; |
1987 | } | 1987 | } |
1988 | secrets = malloc(num_points * sizeof(felem_bytearray)); | 1988 | secrets = calloc(num_points, sizeof(felem_bytearray)); |
1989 | pre_comp = malloc(num_points * 17 * 3 * sizeof(smallfelem)); | 1989 | pre_comp = calloc(num_points, 17 * 3 * sizeof(smallfelem)); |
1990 | if (mixed) | 1990 | if (mixed) |
1991 | tmp_smallfelems = malloc((num_points * 17 + 1) * sizeof(smallfelem)); | 1991 | tmp_smallfelems = malloc((num_points * 17 + 1) * sizeof(smallfelem)); |
1992 | if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_smallfelems == NULL))) { | 1992 | 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, | |||
1998 | * infinity, i.e., they contribute nothing to the linear | 1998 | * infinity, i.e., they contribute nothing to the linear |
1999 | * combination | 1999 | * combination |
2000 | */ | 2000 | */ |
2001 | memset(secrets, 0, num_points * sizeof(felem_bytearray)); | ||
2002 | memset(pre_comp, 0, num_points * 17 * 3 * sizeof(smallfelem)); | ||
2003 | for (i = 0; i < num_points; ++i) { | 2001 | for (i = 0; i < num_points; ++i) { |
2004 | if (i == num) | 2002 | if (i == num) |
2005 | /* | 2003 | /* |
diff --git a/src/lib/libcrypto/ec/ecp_nistp521.c b/src/lib/libcrypto/ec/ecp_nistp521.c index 0c40f08346..6792c5b71d 100644 --- a/src/lib/libcrypto/ec/ecp_nistp521.c +++ b/src/lib/libcrypto/ec/ecp_nistp521.c | |||
@@ -1872,8 +1872,8 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, | |||
1872 | */ | 1872 | */ |
1873 | mixed = 1; | 1873 | mixed = 1; |
1874 | } | 1874 | } |
1875 | secrets = malloc(num_points * sizeof(felem_bytearray)); | 1875 | secrets = calloc(num_points, sizeof(felem_bytearray)); |
1876 | pre_comp = malloc(num_points * 17 * 3 * sizeof(felem)); | 1876 | pre_comp = calloc(num_points, 17 * 3 * sizeof(felem)); |
1877 | if (mixed) | 1877 | if (mixed) |
1878 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); | 1878 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); |
1879 | if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) { | 1879 | 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, | |||
1885 | * infinity, i.e., they contribute nothing to the linear | 1885 | * infinity, i.e., they contribute nothing to the linear |
1886 | * combination | 1886 | * combination |
1887 | */ | 1887 | */ |
1888 | memset(secrets, 0, num_points * sizeof(felem_bytearray)); | ||
1889 | memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem)); | ||
1890 | for (i = 0; i < num_points; ++i) { | 1888 | for (i = 0; i < num_points; ++i) { |
1891 | if (i == num) | 1889 | if (i == num) |
1892 | /* | 1890 | /* |
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index e51ae51098..82c3f875f3 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c | |||
@@ -196,12 +196,10 @@ EVP_PKEY_meth_new(int id, int flags) | |||
196 | { | 196 | { |
197 | EVP_PKEY_METHOD *pmeth; | 197 | EVP_PKEY_METHOD *pmeth; |
198 | 198 | ||
199 | pmeth = malloc(sizeof(EVP_PKEY_METHOD)); | 199 | pmeth = calloc(1, sizeof(EVP_PKEY_METHOD)); |
200 | if (!pmeth) | 200 | if (!pmeth) |
201 | return NULL; | 201 | return NULL; |
202 | 202 | ||
203 | memset(pmeth, 0, sizeof(EVP_PKEY_METHOD)); | ||
204 | |||
205 | pmeth->pkey_id = id; | 203 | pmeth->pkey_id = id; |
206 | pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC; | 204 | pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC; |
207 | 205 | ||
diff --git a/src/lib/libcrypto/pkcs7/bio_ber.c b/src/lib/libcrypto/pkcs7/bio_ber.c index 216d237b4d..fbcbd16abe 100644 --- a/src/lib/libcrypto/pkcs7/bio_ber.c +++ b/src/lib/libcrypto/pkcs7/bio_ber.c | |||
@@ -126,11 +126,9 @@ static int ber_new(BIO *bi) | |||
126 | { | 126 | { |
127 | BIO_BER_CTX *ctx; | 127 | BIO_BER_CTX *ctx; |
128 | 128 | ||
129 | ctx=(BIO_BER_CTX *)malloc(sizeof(BIO_BER_CTX)); | 129 | ctx=calloc(1, sizeof(BIO_BER_CTX)); |
130 | if (ctx == NULL) return(0); | 130 | if (ctx == NULL) return(0); |
131 | 131 | ||
132 | memset((char *)ctx,0,sizeof(BIO_BER_CTX)); | ||
133 | |||
134 | bi->init=0; | 132 | bi->init=0; |
135 | bi->ptr=(char *)ctx; | 133 | bi->ptr=(char *)ctx; |
136 | bi->flags=0; | 134 | bi->flags=0; |
diff --git a/src/lib/libcrypto/store/str_meth.c b/src/lib/libcrypto/store/str_meth.c index 8944824618..0401aaa129 100644 --- a/src/lib/libcrypto/store/str_meth.c +++ b/src/lib/libcrypto/store/str_meth.c | |||
@@ -62,13 +62,11 @@ | |||
62 | 62 | ||
63 | STORE_METHOD *STORE_create_method(char *name) | 63 | STORE_METHOD *STORE_create_method(char *name) |
64 | { | 64 | { |
65 | STORE_METHOD *store_method = (STORE_METHOD *)malloc(sizeof(STORE_METHOD)); | 65 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); |
66 | 66 | ||
67 | if (store_method) | 67 | if (store_method) |
68 | { | ||
69 | memset(store_method, 0, sizeof(*store_method)); | ||
70 | store_method->name = BUF_strdup(name); | 68 | store_method->name = BUF_strdup(name); |
71 | } | 69 | |
72 | return store_method; | 70 | return store_method; |
73 | } | 71 | } |
74 | 72 | ||
diff --git a/src/lib/libcrypto/ts/ts_rsp_sign.c b/src/lib/libcrypto/ts/ts_rsp_sign.c index 0e57105858..a81d4eedf0 100644 --- a/src/lib/libcrypto/ts/ts_rsp_sign.c +++ b/src/lib/libcrypto/ts/ts_rsp_sign.c | |||
@@ -145,11 +145,10 @@ TS_RESP_CTX_new(void) | |||
145 | { | 145 | { |
146 | TS_RESP_CTX *ctx; | 146 | TS_RESP_CTX *ctx; |
147 | 147 | ||
148 | if (!(ctx = (TS_RESP_CTX *) malloc(sizeof(TS_RESP_CTX)))) { | 148 | if (!(ctx = calloc(1, sizeof(TS_RESP_CTX)))) { |
149 | TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); | 149 | TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); |
150 | return NULL; | 150 | return NULL; |
151 | } | 151 | } |
152 | memset(ctx, 0, sizeof(TS_RESP_CTX)); | ||
153 | 152 | ||
154 | /* Setting default callbacks. */ | 153 | /* Setting default callbacks. */ |
155 | ctx->serial_cb = def_serial_cb; | 154 | ctx->serial_cb = def_serial_cb; |
diff --git a/src/lib/libcrypto/ts/ts_verify_ctx.c b/src/lib/libcrypto/ts/ts_verify_ctx.c index 3fc772678c..e0803e9af9 100644 --- a/src/lib/libcrypto/ts/ts_verify_ctx.c +++ b/src/lib/libcrypto/ts/ts_verify_ctx.c | |||
@@ -63,12 +63,11 @@ | |||
63 | TS_VERIFY_CTX * | 63 | TS_VERIFY_CTX * |
64 | TS_VERIFY_CTX_new(void) | 64 | TS_VERIFY_CTX_new(void) |
65 | { | 65 | { |
66 | TS_VERIFY_CTX *ctx = (TS_VERIFY_CTX *) malloc(sizeof(TS_VERIFY_CTX)); | 66 | TS_VERIFY_CTX *ctx = calloc(1, sizeof(TS_VERIFY_CTX)); |
67 | 67 | ||
68 | if (ctx) | 68 | if (!ctx) |
69 | memset(ctx, 0, sizeof(TS_VERIFY_CTX)); | ||
70 | else | ||
71 | TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE); | 69 | TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE); |
70 | |||
72 | return ctx; | 71 | return ctx; |
73 | } | 72 | } |
74 | 73 | ||
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c index db0ef98b72..ff548f4bb8 100644 --- a/src/lib/libcrypto/ui/ui_lib.c +++ b/src/lib/libcrypto/ui/ui_lib.c | |||
@@ -584,12 +584,11 @@ UI_set_method(UI *ui, const UI_METHOD *meth) | |||
584 | UI_METHOD * | 584 | UI_METHOD * |
585 | UI_create_method(char *name) | 585 | UI_create_method(char *name) |
586 | { | 586 | { |
587 | UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD)); | 587 | UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); |
588 | 588 | ||
589 | if (ui_method) { | 589 | if (ui_method) |
590 | memset(ui_method, 0, sizeof(*ui_method)); | ||
591 | ui_method->name = BUF_strdup(name); | 590 | ui_method->name = BUF_strdup(name); |
592 | } | 591 | |
593 | return ui_method; | 592 | return ui_method; |
594 | } | 593 | } |
595 | 594 | ||
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 0024904c20..7da415f27c 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1950,12 +1950,11 @@ X509_STORE_CTX_new(void) | |||
1950 | { | 1950 | { |
1951 | X509_STORE_CTX *ctx; | 1951 | X509_STORE_CTX *ctx; |
1952 | 1952 | ||
1953 | ctx = (X509_STORE_CTX *)malloc(sizeof(X509_STORE_CTX)); | 1953 | ctx = calloc(1, sizeof(X509_STORE_CTX)); |
1954 | if (!ctx) { | 1954 | if (!ctx) { |
1955 | X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); | 1955 | X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); |
1956 | return NULL; | 1956 | return NULL; |
1957 | } | 1957 | } |
1958 | memset(ctx, 0, sizeof(X509_STORE_CTX)); | ||
1959 | return ctx; | 1958 | return ctx; |
1960 | } | 1959 | } |
1961 | 1960 | ||
diff --git a/src/lib/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c index f0d2a0902e..c2cebd936f 100644 --- a/src/lib/libcrypto/x509/x509_vpm.c +++ b/src/lib/libcrypto/x509/x509_vpm.c | |||
@@ -90,8 +90,7 @@ X509_VERIFY_PARAM_new(void) | |||
90 | { | 90 | { |
91 | X509_VERIFY_PARAM *param; | 91 | X509_VERIFY_PARAM *param; |
92 | 92 | ||
93 | param = malloc(sizeof(X509_VERIFY_PARAM)); | 93 | param = calloc(1, sizeof(X509_VERIFY_PARAM)); |
94 | memset(param, 0, sizeof(X509_VERIFY_PARAM)); | ||
95 | x509_verify_param_zero(param); | 94 | x509_verify_param_zero(param); |
96 | return param; | 95 | return param; |
97 | } | 96 | } |
diff --git a/src/lib/libssl/src/crypto/bn/bn_blind.c b/src/lib/libssl/src/crypto/bn/bn_blind.c index 7cced4f67f..bc4027fe13 100644 --- a/src/lib/libssl/src/crypto/bn/bn_blind.c +++ b/src/lib/libssl/src/crypto/bn/bn_blind.c | |||
@@ -139,11 +139,10 @@ BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) | |||
139 | 139 | ||
140 | bn_check_top(mod); | 140 | bn_check_top(mod); |
141 | 141 | ||
142 | if ((ret = (BN_BLINDING *)malloc(sizeof(BN_BLINDING))) == NULL) { | 142 | if ((ret = calloc(1, sizeof(BN_BLINDING))) == NULL) { |
143 | BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE); | 143 | BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE); |
144 | return (NULL); | 144 | return (NULL); |
145 | } | 145 | } |
146 | memset(ret, 0, sizeof(BN_BLINDING)); | ||
147 | if (A != NULL) { | 146 | if (A != NULL) { |
148 | if ((ret->A = BN_dup(A)) == NULL) | 147 | if ((ret->A = BN_dup(A)) == NULL) |
149 | goto err; | 148 | goto err; |
diff --git a/src/lib/libssl/src/crypto/comp/comp_lib.c b/src/lib/libssl/src/crypto/comp/comp_lib.c index 745c802228..64d19df663 100644 --- a/src/lib/libssl/src/crypto/comp/comp_lib.c +++ b/src/lib/libssl/src/crypto/comp/comp_lib.c | |||
@@ -9,11 +9,10 @@ COMP_CTX_new(COMP_METHOD *meth) | |||
9 | { | 9 | { |
10 | COMP_CTX *ret; | 10 | COMP_CTX *ret; |
11 | 11 | ||
12 | if ((ret = (COMP_CTX *)malloc(sizeof(COMP_CTX))) == NULL) { | 12 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { |
13 | /* ZZZZZZZZZZZZZZZZ */ | 13 | /* ZZZZZZZZZZZZZZZZ */ |
14 | return (NULL); | 14 | return (NULL); |
15 | } | 15 | } |
16 | memset(ret, 0, sizeof(COMP_CTX)); | ||
17 | ret->meth = meth; | 16 | ret->meth = meth; |
18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { | 17 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { |
19 | free(ret); | 18 | free(ret); |
diff --git a/src/lib/libssl/src/crypto/ec/ecp_nistp224.c b/src/lib/libssl/src/crypto/ec/ecp_nistp224.c index bd8f65b097..53aced54d5 100644 --- a/src/lib/libssl/src/crypto/ec/ecp_nistp224.c +++ b/src/lib/libssl/src/crypto/ec/ecp_nistp224.c | |||
@@ -1435,8 +1435,8 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, | |||
1435 | */ | 1435 | */ |
1436 | mixed = 1; | 1436 | mixed = 1; |
1437 | } | 1437 | } |
1438 | secrets = malloc(num_points * sizeof(felem_bytearray)); | 1438 | secrets = calloc(num_points, sizeof(felem_bytearray)); |
1439 | pre_comp = malloc(num_points * 17 * 3 * sizeof(felem)); | 1439 | pre_comp = calloc(num_points, 17 * 3 * sizeof(felem)); |
1440 | if (mixed) | 1440 | if (mixed) |
1441 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); | 1441 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); |
1442 | if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) { | 1442 | 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, | |||
1448 | * infinity, i.e., they contribute nothing to the linear | 1448 | * infinity, i.e., they contribute nothing to the linear |
1449 | * combination | 1449 | * combination |
1450 | */ | 1450 | */ |
1451 | memset(secrets, 0, num_points * sizeof(felem_bytearray)); | ||
1452 | memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem)); | ||
1453 | for (i = 0; i < num_points; ++i) { | 1451 | for (i = 0; i < num_points; ++i) { |
1454 | if (i == num) | 1452 | if (i == num) |
1455 | /* the generator */ | 1453 | /* the generator */ |
diff --git a/src/lib/libssl/src/crypto/ec/ecp_nistp256.c b/src/lib/libssl/src/crypto/ec/ecp_nistp256.c index 558c29c5ba..df80cc2b8a 100644 --- a/src/lib/libssl/src/crypto/ec/ecp_nistp256.c +++ b/src/lib/libssl/src/crypto/ec/ecp_nistp256.c | |||
@@ -1985,8 +1985,8 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, | |||
1985 | */ | 1985 | */ |
1986 | mixed = 1; | 1986 | mixed = 1; |
1987 | } | 1987 | } |
1988 | secrets = malloc(num_points * sizeof(felem_bytearray)); | 1988 | secrets = calloc(num_points, sizeof(felem_bytearray)); |
1989 | pre_comp = malloc(num_points * 17 * 3 * sizeof(smallfelem)); | 1989 | pre_comp = calloc(num_points, 17 * 3 * sizeof(smallfelem)); |
1990 | if (mixed) | 1990 | if (mixed) |
1991 | tmp_smallfelems = malloc((num_points * 17 + 1) * sizeof(smallfelem)); | 1991 | tmp_smallfelems = malloc((num_points * 17 + 1) * sizeof(smallfelem)); |
1992 | if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_smallfelems == NULL))) { | 1992 | 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, | |||
1998 | * infinity, i.e., they contribute nothing to the linear | 1998 | * infinity, i.e., they contribute nothing to the linear |
1999 | * combination | 1999 | * combination |
2000 | */ | 2000 | */ |
2001 | memset(secrets, 0, num_points * sizeof(felem_bytearray)); | ||
2002 | memset(pre_comp, 0, num_points * 17 * 3 * sizeof(smallfelem)); | ||
2003 | for (i = 0; i < num_points; ++i) { | 2001 | for (i = 0; i < num_points; ++i) { |
2004 | if (i == num) | 2002 | if (i == num) |
2005 | /* | 2003 | /* |
diff --git a/src/lib/libssl/src/crypto/ec/ecp_nistp521.c b/src/lib/libssl/src/crypto/ec/ecp_nistp521.c index 0c40f08346..6792c5b71d 100644 --- a/src/lib/libssl/src/crypto/ec/ecp_nistp521.c +++ b/src/lib/libssl/src/crypto/ec/ecp_nistp521.c | |||
@@ -1872,8 +1872,8 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, | |||
1872 | */ | 1872 | */ |
1873 | mixed = 1; | 1873 | mixed = 1; |
1874 | } | 1874 | } |
1875 | secrets = malloc(num_points * sizeof(felem_bytearray)); | 1875 | secrets = calloc(num_points, sizeof(felem_bytearray)); |
1876 | pre_comp = malloc(num_points * 17 * 3 * sizeof(felem)); | 1876 | pre_comp = calloc(num_points, 17 * 3 * sizeof(felem)); |
1877 | if (mixed) | 1877 | if (mixed) |
1878 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); | 1878 | tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); |
1879 | if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) { | 1879 | 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, | |||
1885 | * infinity, i.e., they contribute nothing to the linear | 1885 | * infinity, i.e., they contribute nothing to the linear |
1886 | * combination | 1886 | * combination |
1887 | */ | 1887 | */ |
1888 | memset(secrets, 0, num_points * sizeof(felem_bytearray)); | ||
1889 | memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem)); | ||
1890 | for (i = 0; i < num_points; ++i) { | 1888 | for (i = 0; i < num_points; ++i) { |
1891 | if (i == num) | 1889 | if (i == num) |
1892 | /* | 1890 | /* |
diff --git a/src/lib/libssl/src/crypto/evp/pmeth_lib.c b/src/lib/libssl/src/crypto/evp/pmeth_lib.c index e51ae51098..82c3f875f3 100644 --- a/src/lib/libssl/src/crypto/evp/pmeth_lib.c +++ b/src/lib/libssl/src/crypto/evp/pmeth_lib.c | |||
@@ -196,12 +196,10 @@ EVP_PKEY_meth_new(int id, int flags) | |||
196 | { | 196 | { |
197 | EVP_PKEY_METHOD *pmeth; | 197 | EVP_PKEY_METHOD *pmeth; |
198 | 198 | ||
199 | pmeth = malloc(sizeof(EVP_PKEY_METHOD)); | 199 | pmeth = calloc(1, sizeof(EVP_PKEY_METHOD)); |
200 | if (!pmeth) | 200 | if (!pmeth) |
201 | return NULL; | 201 | return NULL; |
202 | 202 | ||
203 | memset(pmeth, 0, sizeof(EVP_PKEY_METHOD)); | ||
204 | |||
205 | pmeth->pkey_id = id; | 203 | pmeth->pkey_id = id; |
206 | pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC; | 204 | pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC; |
207 | 205 | ||
diff --git a/src/lib/libssl/src/crypto/pkcs7/bio_ber.c b/src/lib/libssl/src/crypto/pkcs7/bio_ber.c index 216d237b4d..fbcbd16abe 100644 --- a/src/lib/libssl/src/crypto/pkcs7/bio_ber.c +++ b/src/lib/libssl/src/crypto/pkcs7/bio_ber.c | |||
@@ -126,11 +126,9 @@ static int ber_new(BIO *bi) | |||
126 | { | 126 | { |
127 | BIO_BER_CTX *ctx; | 127 | BIO_BER_CTX *ctx; |
128 | 128 | ||
129 | ctx=(BIO_BER_CTX *)malloc(sizeof(BIO_BER_CTX)); | 129 | ctx=calloc(1, sizeof(BIO_BER_CTX)); |
130 | if (ctx == NULL) return(0); | 130 | if (ctx == NULL) return(0); |
131 | 131 | ||
132 | memset((char *)ctx,0,sizeof(BIO_BER_CTX)); | ||
133 | |||
134 | bi->init=0; | 132 | bi->init=0; |
135 | bi->ptr=(char *)ctx; | 133 | bi->ptr=(char *)ctx; |
136 | bi->flags=0; | 134 | bi->flags=0; |
diff --git a/src/lib/libssl/src/crypto/store/str_meth.c b/src/lib/libssl/src/crypto/store/str_meth.c index 8944824618..0401aaa129 100644 --- a/src/lib/libssl/src/crypto/store/str_meth.c +++ b/src/lib/libssl/src/crypto/store/str_meth.c | |||
@@ -62,13 +62,11 @@ | |||
62 | 62 | ||
63 | STORE_METHOD *STORE_create_method(char *name) | 63 | STORE_METHOD *STORE_create_method(char *name) |
64 | { | 64 | { |
65 | STORE_METHOD *store_method = (STORE_METHOD *)malloc(sizeof(STORE_METHOD)); | 65 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); |
66 | 66 | ||
67 | if (store_method) | 67 | if (store_method) |
68 | { | ||
69 | memset(store_method, 0, sizeof(*store_method)); | ||
70 | store_method->name = BUF_strdup(name); | 68 | store_method->name = BUF_strdup(name); |
71 | } | 69 | |
72 | return store_method; | 70 | return store_method; |
73 | } | 71 | } |
74 | 72 | ||
diff --git a/src/lib/libssl/src/crypto/ts/ts_rsp_sign.c b/src/lib/libssl/src/crypto/ts/ts_rsp_sign.c index 0e57105858..a81d4eedf0 100644 --- a/src/lib/libssl/src/crypto/ts/ts_rsp_sign.c +++ b/src/lib/libssl/src/crypto/ts/ts_rsp_sign.c | |||
@@ -145,11 +145,10 @@ TS_RESP_CTX_new(void) | |||
145 | { | 145 | { |
146 | TS_RESP_CTX *ctx; | 146 | TS_RESP_CTX *ctx; |
147 | 147 | ||
148 | if (!(ctx = (TS_RESP_CTX *) malloc(sizeof(TS_RESP_CTX)))) { | 148 | if (!(ctx = calloc(1, sizeof(TS_RESP_CTX)))) { |
149 | TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); | 149 | TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); |
150 | return NULL; | 150 | return NULL; |
151 | } | 151 | } |
152 | memset(ctx, 0, sizeof(TS_RESP_CTX)); | ||
153 | 152 | ||
154 | /* Setting default callbacks. */ | 153 | /* Setting default callbacks. */ |
155 | ctx->serial_cb = def_serial_cb; | 154 | ctx->serial_cb = def_serial_cb; |
diff --git a/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c b/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c index 3fc772678c..e0803e9af9 100644 --- a/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c +++ b/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c | |||
@@ -63,12 +63,11 @@ | |||
63 | TS_VERIFY_CTX * | 63 | TS_VERIFY_CTX * |
64 | TS_VERIFY_CTX_new(void) | 64 | TS_VERIFY_CTX_new(void) |
65 | { | 65 | { |
66 | TS_VERIFY_CTX *ctx = (TS_VERIFY_CTX *) malloc(sizeof(TS_VERIFY_CTX)); | 66 | TS_VERIFY_CTX *ctx = calloc(1, sizeof(TS_VERIFY_CTX)); |
67 | 67 | ||
68 | if (ctx) | 68 | if (!ctx) |
69 | memset(ctx, 0, sizeof(TS_VERIFY_CTX)); | ||
70 | else | ||
71 | TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE); | 69 | TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE); |
70 | |||
72 | return ctx; | 71 | return ctx; |
73 | } | 72 | } |
74 | 73 | ||
diff --git a/src/lib/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c index db0ef98b72..ff548f4bb8 100644 --- a/src/lib/libssl/src/crypto/ui/ui_lib.c +++ b/src/lib/libssl/src/crypto/ui/ui_lib.c | |||
@@ -584,12 +584,11 @@ UI_set_method(UI *ui, const UI_METHOD *meth) | |||
584 | UI_METHOD * | 584 | UI_METHOD * |
585 | UI_create_method(char *name) | 585 | UI_create_method(char *name) |
586 | { | 586 | { |
587 | UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD)); | 587 | UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); |
588 | 588 | ||
589 | if (ui_method) { | 589 | if (ui_method) |
590 | memset(ui_method, 0, sizeof(*ui_method)); | ||
591 | ui_method->name = BUF_strdup(name); | 590 | ui_method->name = BUF_strdup(name); |
592 | } | 591 | |
593 | return ui_method; | 592 | return ui_method; |
594 | } | 593 | } |
595 | 594 | ||
diff --git a/src/lib/libssl/src/crypto/x509/x509_vfy.c b/src/lib/libssl/src/crypto/x509/x509_vfy.c index 0024904c20..7da415f27c 100644 --- a/src/lib/libssl/src/crypto/x509/x509_vfy.c +++ b/src/lib/libssl/src/crypto/x509/x509_vfy.c | |||
@@ -1950,12 +1950,11 @@ X509_STORE_CTX_new(void) | |||
1950 | { | 1950 | { |
1951 | X509_STORE_CTX *ctx; | 1951 | X509_STORE_CTX *ctx; |
1952 | 1952 | ||
1953 | ctx = (X509_STORE_CTX *)malloc(sizeof(X509_STORE_CTX)); | 1953 | ctx = calloc(1, sizeof(X509_STORE_CTX)); |
1954 | if (!ctx) { | 1954 | if (!ctx) { |
1955 | X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); | 1955 | X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); |
1956 | return NULL; | 1956 | return NULL; |
1957 | } | 1957 | } |
1958 | memset(ctx, 0, sizeof(X509_STORE_CTX)); | ||
1959 | return ctx; | 1958 | return ctx; |
1960 | } | 1959 | } |
1961 | 1960 | ||
diff --git a/src/lib/libssl/src/crypto/x509/x509_vpm.c b/src/lib/libssl/src/crypto/x509/x509_vpm.c index f0d2a0902e..c2cebd936f 100644 --- a/src/lib/libssl/src/crypto/x509/x509_vpm.c +++ b/src/lib/libssl/src/crypto/x509/x509_vpm.c | |||
@@ -90,8 +90,7 @@ X509_VERIFY_PARAM_new(void) | |||
90 | { | 90 | { |
91 | X509_VERIFY_PARAM *param; | 91 | X509_VERIFY_PARAM *param; |
92 | 92 | ||
93 | param = malloc(sizeof(X509_VERIFY_PARAM)); | 93 | param = calloc(1, sizeof(X509_VERIFY_PARAM)); |
94 | memset(param, 0, sizeof(X509_VERIFY_PARAM)); | ||
95 | x509_verify_param_zero(param); | 94 | x509_verify_param_zero(param); |
96 | return param; | 95 | return param; |
97 | } | 96 | } |