Hi tech@ patch set for libssl Index: bn_blind.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/bn/bn_blind.c,v retrieving revision 1.9 diff -u -p -r1.9 bn_blind.c --- bn_blind.c 8 May 2014 13:20:49 -0000 1.9 +++ bn_blind.c 24 May 2014 21:09:40 -0000 @@ -139,11 +139,10 @@ BN_BLINDING_new(const BIGNUM *A, const B 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;
Index: comp_lib.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/comp/comp_lib.c,v retrieving revision 1.5 diff -u -p -r1.5 comp_lib.c --- comp_lib.c 26 Apr 2014 13:04:24 -0000 1.5 +++ comp_lib.c 24 May 2014 21:12:44 -0000 @@ -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); Index: pmeth_lib.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/evp/pmeth_lib.c,v retrieving revision 1.3 diff -u -p -r1.3 pmeth_lib.c --- pmeth_lib.c 7 May 2014 17:42:51 -0000 1.3 +++ pmeth_lib.c 24 May 2014 21:30:17 -0000 @@ -196,11 +196,9 @@ 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; Index: bio_ber.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/pkcs7/bio_ber.c,v retrieving revision 1.9 diff -u -p -r1.9 bio_ber.c --- bio_ber.c 27 Apr 2014 20:26:49 -0000 1.9 +++ bio_ber.c 24 May 2014 21:32:22 -0000 @@ -126,10 +126,8 @@ 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; Index: ecp_nistp224.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/ec/ecp_nistp224.c,v retrieving revision 1.7 diff -u -p -r1.7 ecp_nistp224.c --- ecp_nistp224.c 15 May 2014 11:25:59 -0000 1.7 +++ ecp_nistp224.c 25 May 2014 09:41:35 -0000 @@ -1435,8 +1435,8 @@ ec_GFp_nistp224_points_mul(const EC_GROU */ 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_GROU * 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 */ Index: ecp_nistp256.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/ec/ecp_nistp256.c,v retrieving revision 1.7 diff -u -p -r1.7 ecp_nistp256.c --- ecp_nistp256.c 15 May 2014 11:25:59 -0000 1.7 +++ ecp_nistp256.c 25 May 2014 09:43:43 -0000 @@ -1985,8 +1985,8 @@ ec_GFp_nistp256_points_mul(const EC_GROU */ 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_GROU * 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) /* Index: ecp_nistp521.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/ec/ecp_nistp521.c,v retrieving revision 1.8 diff -u -p -r1.8 ecp_nistp521.c --- ecp_nistp521.c 15 May 2014 11:25:59 -0000 1.8 +++ ecp_nistp521.c 25 May 2014 09:45:06 -0000 @@ -1872,8 +1872,8 @@ ec_GFp_nistp521_points_mul(const EC_GROU */ 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_GROU * 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) /* Index: str_meth.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/store/str_meth.c,v retrieving revision 1.2 diff -u -p -r1.2 str_meth.c --- str_meth.c 17 Apr 2014 13:37:49 -0000 1.2 +++ str_meth.c 25 May 2014 18:49:40 -0000 @@ -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; } Index: ts_rsp_sign.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/ts/ts_rsp_sign.c,v retrieving revision 1.11 diff -u -p -r1.11 ts_rsp_sign.c --- ts_rsp_sign.c 22 May 2014 17:27:50 -0000 1.11 +++ ts_rsp_sign.c 25 May 2014 07:59:22 -0000 @@ -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; Index: ts_verify_ctx.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/ts/ts_verify_ctx.c,v retrieving revision 1.3 diff -u -p -r1.3 ts_verify_ctx.c --- ts_verify_ctx.c 21 Apr 2014 16:32:06 -0000 1.3 +++ ts_verify_ctx.c 25 May 2014 08:03:24 -0000 @@ -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; } Index: ui_lib.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/ui/ui_lib.c,v retrieving revision 1.20 diff -u -p -r1.20 ui_lib.c --- ui_lib.c 24 May 2014 09:16:08 -0000 1.20 +++ ui_lib.c 25 May 2014 08:06:08 -0000 @@ -584,12 +584,11 @@ UI_set_method(UI *ui, const UI_METHOD *m 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; } Index: x509_vfy.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/x509/x509_vfy.c,v retrieving revision 1.25 diff -u -p -r1.25 x509_vfy.c --- x509_vfy.c 20 Apr 2014 16:10:10 -0000 1.25 +++ x509_vfy.c 25 May 2014 08:08:08 -0000 @@ -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; } Index: x509_vpm.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/x509/x509_vpm.c,v retrieving revision 1.4 diff -u -p -r1.4 x509_vpm.c --- x509_vpm.c 20 Apr 2014 16:10:10 -0000 1.4 +++ x509_vpm.c 25 May 2014 08:09:13 -0000 @@ -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; }