There are many places (nearly 50) where we malloc and then memset.
Add an OPENSSL_zalloc routine to encapsulate that.
(Missed one conversion; thanks Richard)
Also fixes GH328
Reviewed-by: Richard Levitte <levitte@openssl.org>
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(*ameth));
+ EVP_PKEY_ASN1_METHOD *ameth = OPENSSL_zalloc(sizeof(*ameth));
+
if (!ameth)
return NULL;
- memset(ameth, 0, sizeof(*ameth));
ameth->pkey_id = id;
ameth->pkey_base_id = id;
ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
return 1;
}
}
- *pval = OPENSSL_malloc(it->size);
+ *pval = OPENSSL_zalloc(it->size);
if (!*pval)
goto memerr;
- memset(*pval, 0, it->size);
asn1_set_choice_selector(pval, -1, it);
if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
goto auxerr;
return 1;
}
}
- *pval = OPENSSL_malloc(it->size);
+ *pval = OPENSSL_zalloc(it->size);
if (!*pval)
goto memerr;
- memset(*pval, 0, it->size);
asn1_do_lock(pval, 0, it);
asn1_enc_init(pval, it);
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
{
X509_PKEY *ret = NULL;
- ret = OPENSSL_malloc(sizeof(*ret));
+ ret = OPENSSL_zalloc(sizeof(*ret));
if (!ret)
goto err;
- memset(ret, 0, sizeof(*ret));
ret->version = 0;
ret->enc_algor = X509_ALGOR_new();
{
BIO_ACCEPT *ret;
- if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
return (NULL);
-
- memset(ret, 0, sizeof(*ret));
ret->accept_sock = INVALID_SOCKET;
ret->bind_mode = BIO_BIND_NORMAL;
return (ret);
{
BIO_CONNECT *ret;
- if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
return (NULL);
ret->state = BIO_CONN_S_BEFORE;
ret->param_hostname = NULL;
ret->param_port = NULL;
ret->info_callback = NULL;
- ret->nbio = 0;
- ret->ip[0] = 0;
- ret->ip[1] = 0;
- ret->ip[2] = 0;
- ret->ip[3] = 0;
- ret->port = 0;
- memset(&ret->them, 0, sizeof(ret->them));
return (ret);
}
static int dgram_new(BIO *bi)
{
- bio_dgram_data *data = NULL;
+ bio_dgram_data *data = OPENSSL_zalloc(sizeof(*data));
- bi->init = 0;
- bi->num = 0;
- data = OPENSSL_malloc(sizeof(*data));
if (data == NULL)
return 0;
- memset(data, 0, sizeof(*data));
+ bi->init = 0;
+ bi->num = 0;
bi->ptr = data;
-
bi->flags = 0;
return (1);
}
* connected socket won't use it.
*/
sockopt_len = (socklen_t) (sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t));
- authchunks = OPENSSL_malloc(sockopt_len);
+ authchunks = OPENSSL_zalloc(sockopt_len);
if (!authchunks) {
BIO_vfree(bio);
return (NULL);
}
- memset(authchunks, 0, sockopt_len);
- ret =
- getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks,
+ ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks,
&sockopt_len);
-
if (ret < 0) {
OPENSSL_free(authchunks);
BIO_vfree(bio);
bi->init = 0;
bi->num = 0;
- data = OPENSSL_malloc(sizeof(*data));
+ data = OPENSSL_zalloc(sizeof(*data));
if (data == NULL)
return 0;
- memset(data, 0, sizeof(*data));
# ifdef SCTP_PR_SCTP_NONE
data->prinfo.pr_policy = SCTP_PR_SCTP_NONE;
# endif
bn_check_top(mod);
- if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- memset(ret, 0, sizeof(*ret));
if (A != NULL) {
if ((ret->A = BN_dup(A)) == NULL)
goto err;
{
void *p;
- p = OPENSSL_malloc(no * size);
- if (p)
- memset(p, 0, no * size);
+ p = OPENSSL_zalloc(no * size);
return p;
}
{
COMP_CTX *ret;
- if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
return (NULL);
- memset(ret, 0, sizeof(*ret));
ret->meth = meth;
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
OPENSSL_free(ret);
*/
default_DSO_meth = DSO_METHOD_openssl();
}
- ret = OPENSSL_malloc(sizeof(*ret));
+ ret = OPENSSL_zalloc(sizeof(*ret));
if (ret == NULL) {
DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- memset(ret, 0, sizeof(*ret));
ret->meth_data = sk_void_new_null();
if (ret->meth_data == NULL) {
/* sk_new doesn't generate any errors so we do */
return (NULL);
}
- result = OPENSSL_malloc(sizeof(*result));
+ result = OPENSSL_zalloc(sizeof(*result));
if (result == NULL) {
DSOerr(DSO_F_WIN32_SPLITTER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- memset(result, 0, sizeof(*result));
position = IN_DEVICE;
if ((filename[0] == '\\' && filename[1] == '\\')
static NISTP224_PRE_COMP *nistp224_pre_comp_new()
{
- NISTP224_PRE_COMP *ret = NULL;
- ret = OPENSSL_malloc(sizeof(*ret));
+ NISTP224_PRE_COMP *ret = OPENSSL_zalloc(sizeof(*ret));
+
if (!ret) {
ECerr(EC_F_NISTP224_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
}
- memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp));
ret->references = 1;
return ret;
}
*/
mixed = 1;
}
- secrets = OPENSSL_malloc(sizeof(*secrets) * num_points);
- pre_comp = OPENSSL_malloc(sizeof(*pre_comp) * num_points);
+ secrets = OPENSSL_zalloc(sizeof(*secrets) * num_points);
+ pre_comp = OPENSSL_zalloc(sizeof(*pre_comp) * num_points);
if (mixed)
tmp_felems =
OPENSSL_malloc(sizeof(felem) * (num_points * 17 + 1));
* we treat NULL scalars as 0, and NULL points as points at infinity,
* i.e., they contribute nothing to the linear combination
*/
- memset(secrets, 0, sizeof(*secrets) * num_points);
- memset(pre_comp, 0, sizeof(*pre_comp) * num_points);
for (i = 0; i < num_points; ++i) {
if (i == num)
/* the generator */
static NISTP521_PRE_COMP *nistp521_pre_comp_new()
{
- NISTP521_PRE_COMP *ret = OPENSSL_malloc(sizeof(*ret));
+ NISTP521_PRE_COMP *ret = OPENSSL_zalloc(sizeof(*ret));
if (!ret) {
ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
}
- memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp));
ret->references = 1;
return ret;
}
*/
mixed = 1;
}
- secrets = OPENSSL_malloc(sizeof(*secrets) * num_points);
- pre_comp = OPENSSL_malloc(sizeof(*pre_comp) * num_points);
+ secrets = OPENSSL_zalloc(sizeof(*secrets) * num_points);
+ pre_comp = OPENSSL_zalloc(sizeof(*pre_comp) * num_points);
if (mixed)
tmp_felems =
OPENSSL_malloc(sizeof(*tmp_felems) * (num_points * 17 + 1));
* we treat NULL scalars as 0, and NULL points as points at infinity,
* i.e., they contribute nothing to the linear combination
*/
- memset(secrets, 0, sizeof(*secrets) * num_points);
- memset(pre_comp, 0, sizeof(*pre_comp) * num_points);
for (i = 0; i < num_points; ++i) {
if (i == num)
/*
bits = BN_num_bits(a);
bytes = BN_num_bytes(a);
- b = OPENSSL_malloc(bytes);
+ b = OPENSSL_zalloc(bytes);
if (b == NULL)
return (1);
- memset(b, 0, bytes);
crp->crp_p = (caddr_t) b;
crp->crp_nbits = bits;
*/
static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
{
- dynamic_data_ctx *c = OPENSSL_malloc(sizeof(*c));
+ dynamic_data_ctx *c = OPENSSL_zalloc(sizeof(*c));
if (!c) {
ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE);
return 0;
}
- memset(c, 0, sizeof(*c));
c->dynamic_dso = NULL;
c->v_check = NULL;
c->bind_engine = NULL;
{
ENGINE *ret;
- ret = OPENSSL_malloc(sizeof(*ret));
+ ret = OPENSSL_zalloc(sizeof(*ret));
if (ret == NULL) {
ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
- memset(ret, 0, sizeof(*ret));
ret->struct_ref = 1;
engine_ref_debug(ret, 0, 1)
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data);
ctx->cipher = cipher;
if (ctx->cipher->ctx_size) {
- ctx->cipher_data = OPENSSL_malloc(ctx->cipher->ctx_size);
+ ctx->cipher_data = OPENSSL_zalloc(ctx->cipher->ctx_size);
if (!ctx->cipher_data) {
EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE);
return 0;
}
- memset(ctx->cipher_data, 0, ctx->cipher->ctx_size);
} else {
ctx->cipher_data = NULL;
}
{
EVP_PKEY_METHOD *pmeth;
- pmeth = OPENSSL_malloc(sizeof(*pmeth));
+ pmeth = OPENSSL_zalloc(sizeof(*pmeth));
if (!pmeth)
return NULL;
- memset(pmeth, 0, sizeof(*pmeth));
-
pmeth->pkey_id = id;
pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC;
-
pmeth->init = 0;
pmeth->copy = 0;
pmeth->cleanup = 0;
return ret;
}
+void *CRYPTO_zalloc(int num, const char *file, int line)
+{
+ void *ret = CRYPTO_malloc(num, file, line);
+
+ if (ret != NULL)
+ memset(ret, 0, num);
+ return ret;
+}
+
char *CRYPTO_strdup(const char *str, const char *file, int line)
{
char *ret = CRYPTO_malloc(strlen(str) + 1, file, line);
- if (ret == NULL)
- return NULL;
-
- strcpy(ret, str);
+ if (ret != NULL)
+ strcpy(ret, str);
return ret;
}
pqueue_s *pqueue_new()
{
- pqueue_s *pq = OPENSSL_malloc(sizeof(*pq));
- if (pq == NULL)
- return NULL;
+ pqueue_s *pq = OPENSSL_zalloc(sizeof(*pq));
- memset(pq, 0, sizeof(*pq));
return pq;
}
j = 1;
for (i = 0; i < 6; i++)
j += bn_get_top(*t[i]);
- if ((p = OPENSSL_malloc((off + j) * sizeof(BN_ULONG))) == NULL) {
+ if ((p = OPENSSL_malloc((off + j) * sizeof(*p))) == NULL) {
RSAerr(RSA_F_RSA_MEMORY_LOCK, ERR_R_MALLOC_FAILURE);
return (0);
}
if (num < 11)
goto err;
- em = OPENSSL_malloc(num);
+ em = OPENSSL_zalloc(num);
if (em == NULL) {
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, ERR_R_MALLOC_FAILURE);
return -1;
}
- memset(em, 0, num);
/*
* Always do this zero-padding copy (even when num == flen) to avoid
* leaking that information. The copy still leaks some side-channel
for (i = sh.bittable_size; i; i >>= 1)
sh.freelist_size++;
- sh.freelist = OPENSSL_malloc(sh.freelist_size * sizeof (char *));
+ sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof (char *));
OPENSSL_assert(sh.freelist != NULL);
if (sh.freelist == NULL)
goto err;
- memset(sh.freelist, 0, sh.freelist_size * sizeof (char *));
- sh.bittable = OPENSSL_malloc(sh.bittable_size >> 3);
+ sh.bittable = OPENSSL_zalloc(sh.bittable_size >> 3);
OPENSSL_assert(sh.bittable != NULL);
if (sh.bittable == NULL)
goto err;
- memset(sh.bittable, 0, sh.bittable_size >> 3);
- sh.bitmalloc = OPENSSL_malloc(sh.bittable_size >> 3);
+ sh.bitmalloc = OPENSSL_zalloc(sh.bittable_size >> 3);
OPENSSL_assert(sh.bitmalloc != NULL);
if (sh.bitmalloc == NULL)
goto err;
- memset(sh.bitmalloc, 0, sh.bittable_size >> 3);
/* Allocate space for heap, and two extra pages as guards */
#ifdef _SC_PAGE_SIZE
STORE_OBJECT *STORE_OBJECT_new(void)
{
- STORE_OBJECT *object = OPENSSL_malloc(sizeof(*object));
- if (object)
- memset(object, 0, sizeof(*object));
+ STORE_OBJECT *object = OPENSSL_zalloc(sizeof(*object));
return object;
}
OPENSSL_ITEM attributes[],
OPENSSL_ITEM parameters[])
{
- struct mem_ctx_st *context = OPENSSL_malloc(sizeof(*context));
+ struct mem_ctx_st *context = OPENSSL_zalloc(sizeof(*context));
void *attribute_context = NULL;
STORE_ATTR_INFO *attrs = NULL;
STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE);
return 0;
}
- memset(context, 0, sizeof(*context));
attribute_context = STORE_parse_attrs_start(attributes);
if (!attribute_context) {
STORE_METHOD *STORE_create_method(char *name)
{
- STORE_METHOD *store_method = OPENSSL_malloc(sizeof(*store_method));
+ STORE_METHOD *store_method = OPENSSL_zalloc(sizeof(*store_method));
- if (store_method) {
- memset(store_method, 0, sizeof(*store_method));
+ if (store_method)
store_method->name = BUF_strdup(name);
- }
return store_method;
}
{
TS_RESP_CTX *ctx;
- if ((ctx = OPENSSL_malloc(sizeof(*ctx))) == NULL) {
+ if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) {
TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
- memset(ctx, 0, sizeof(*ctx));
/* Setting default callbacks. */
ctx->serial_cb = def_serial_cb;
TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
{
- TS_VERIFY_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
+ TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
- if (ctx)
- memset(ctx, 0, sizeof(*ctx));
- else
+ if (!ctx)
TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
return ctx;
}
UI_METHOD *UI_create_method(char *name)
{
- UI_METHOD *ui_method = OPENSSL_malloc(sizeof(*ui_method));
+ UI_METHOD *ui_method = OPENSSL_zalloc(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;
}
X509_STORE_CTX *X509_STORE_CTX_new(void)
{
- X509_STORE_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
+ X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
if (!ctx) {
X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
- memset(ctx, 0, sizeof(*ctx));
return ctx;
}
X509_VERIFY_PARAM *param;
X509_VERIFY_PARAM_ID *paramid;
- param = OPENSSL_malloc(sizeof(*param));
+ param = OPENSSL_zalloc(sizeof(*param));
if (!param)
return NULL;
- memset(param, 0, sizeof(*param));
-
- paramid = OPENSSL_malloc(sizeof(*paramid));
+ param->id = paramid = OPENSSL_zalloc(sizeof(*paramid));
if (!paramid) {
OPENSSL_free(param);
return NULL;
}
- memset(paramid, 0, sizeof(*paramid));
- /* Exotic platforms may have non-zero bit representation of NULL */
- paramid->hosts = NULL;
- paramid->peername = NULL;
- paramid->email = NULL;
- paramid->ip = NULL;
-
- param->id = paramid;
x509_verify_param_zero(param);
return param;
}
}
/* If we get this far initialize the tree */
-
tree = OPENSSL_malloc(sizeof(*tree));
-
if (!tree)
return 0;
-
- tree->flags = 0;
- tree->levels = OPENSSL_malloc(sizeof(*tree->levels) * n);
- tree->nlevel = 0;
- tree->extra_data = NULL;
- tree->auth_policies = NULL;
- tree->user_policies = NULL;
-
+ tree->levels = OPENSSL_zalloc(sizeof(*tree->levels) * n);
if (!tree->levels) {
OPENSSL_free(tree);
return 0;
}
-
- memset(tree->levels, 0, sizeof(*tree->levels) * n);
+ tree->flags = 0;
+ tree->extra_data = NULL;
+ tree->auth_policies = NULL;
+ tree->user_policies = NULL;
tree->nlevel = n;
level = tree->levels;
struct gost_pmeth_data *data;
EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
- data = OPENSSL_malloc(sizeof(*data));
+ data = OPENSSL_zalloc(sizeof(*data));
if (!data)
return 0;
- memset(data, 0, sizeof(*data));
if (pkey && EVP_PKEY_get0(pkey)) {
switch (EVP_PKEY_base_id(pkey)) {
case NID_id_GostR3410_2001:
/* -------- PKEY_METHOD for GOST MAC algorithm --------------------*/
static int pkey_gost_mac_init(EVP_PKEY_CTX *ctx)
{
- struct gost_mac_pmeth_data *data = OPENSSL_malloc(sizeof(*data));
+ struct gost_mac_pmeth_data *data = OPENSSL_zalloc(sizeof(*data));
if (!data)
return 0;
- memset(data, 0, sizeof(*data));
EVP_PKEY_CTX_set_data(ctx, data);
return 1;
}
# define is_MemCheck_on() CRYPTO_is_mem_check_on()
# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
+# define OPENSSL_zalloc(num) CRYPTO_zalloc((int)num,__FILE__,__LINE__)
# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
# define OPENSSL_realloc(addr,num) \
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
void (**so) (long), long (**go) (void));
void *CRYPTO_malloc(int num, const char *file, int line);
+void *CRYPTO_zalloc(int num, const char *file, int line);
char *CRYPTO_strdup(const char *str, const char *file, int line);
void CRYPTO_free(void *ptr);
void CRYPTO_clear_free(void *ptr, size_t num);
static int ssl_new(BIO *bi)
{
- BIO_SSL *bs = OPENSSL_malloc(sizeof(*bs));
+ BIO_SSL *bs = OPENSSL_zalloc(sizeof(*bs));
if (bs == NULL) {
BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE);
return (0);
}
- memset(bs, 0, sizeof(*bs));
bi->init = 0;
bi->ptr = (char *)bs;
bi->flags = 0;
/* Initialize reassembly bitmask if necessary */
if (reassembly) {
- bitmask = OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len));
+ bitmask = OPENSSL_zalloc(RSMBLY_BITMASK_SIZE(frag_len));
if (bitmask == NULL) {
OPENSSL_free(buf);
OPENSSL_free(frag);
return NULL;
}
- memset(bitmask, 0, RSMBLY_BITMASK_SIZE(frag_len));
}
frag->reassembly = bitmask;
if (!ssl3_new(s))
return (0);
- if ((d1 = OPENSSL_malloc(sizeof(*d1))) == NULL) {
+ if ((d1 = OPENSSL_zalloc(sizeof(*d1))) == NULL) {
ssl3_free(s);
return (0);
}
- memset(d1, 0, sizeof(*d1));
d1->buffered_messages = pqueue_new();
d1->sent_messages = pqueue_new();
{
SSL3_STATE *s3;
- if ((s3 = OPENSSL_malloc(sizeof(*s3))) == NULL)
+ if ((s3 = OPENSSL_zalloc(sizeof(*s3))) == NULL)
goto err;
- memset(s3, 0, sizeof(*s3));
s->s3 = s3;
#ifndef OPENSSL_NO_SRP
CERT *ssl_cert_new(void)
{
- CERT *ret = OPENSSL_malloc(sizeof(*ret));
+ CERT *ret = OPENSSL_zalloc(sizeof(*ret));
if (ret == NULL) {
SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- memset(ret, 0, sizeof(*ret));
ret->key = &(ret->pkeys[SSL_PKEY_RSA_ENC]);
ret->references = 1;
CERT *ssl_cert_dup(CERT *cert)
{
- CERT *ret = OPENSSL_malloc(sizeof(*ret));
+ CERT *ret = OPENSSL_zalloc(sizeof(*ret));
int i;
if (ret == NULL) {
return (NULL);
}
- memset(ret, 0, sizeof(*ret));
-
ret->key = &ret->pkeys[cert->key - cert->pkeys];
#ifndef OPENSSL_NO_RSA
curr = curr->next;
}
- number_uses = OPENSSL_malloc(sizeof(int) * (max_strength_bits + 1));
+ number_uses = OPENSSL_zalloc(sizeof(int) * (max_strength_bits + 1));
if (!number_uses) {
SSLerr(SSL_F_SSL_CIPHER_STRENGTH_SORT, ERR_R_MALLOC_FAILURE);
return (0);
}
- memset(number_uses, 0, sizeof(int) * (max_strength_bits + 1));
/*
* Now find the strength_bits values actually used
return (NULL);
}
- s = OPENSSL_malloc(sizeof(*s));
+ s = OPENSSL_zalloc(sizeof(*s));
if (s == NULL)
goto err;
- memset(s, 0, sizeof(*s));
RECORD_LAYER_init(&s->rlayer, s);
SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);
goto err;
}
- ret = OPENSSL_malloc(sizeof(*ret));
+ ret = OPENSSL_zalloc(sizeof(*ret));
if (ret == NULL)
goto err;
- memset(ret, 0, sizeof(*ret));
-
ret->method = meth;
-
ret->cert_store = NULL;
ret->session_cache_mode = SSL_SESS_CACHE_SERVER;
ret->session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT;
ret->get_session_cb = 0;
ret->generate_session_id = 0;
- memset(&ret->stats, 0, sizeof(ret->stats));
-
ret->references = 1;
ret->quiet_shutdown = 0;
ret->info_callback = NULL;
{
SSL_SESSION *ss;
- ss = OPENSSL_malloc(sizeof(*ss));
+ ss = OPENSSL_zalloc(sizeof(*ss));
if (ss == NULL) {
SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
return (0);
}
- memset(ss, 0, sizeof(*ss));
ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */
ss->references = 1;
goto builtin_err;
}
buf_len = 2 * bn_len;
- if ((raw_buf = OPENSSL_malloc(buf_len)) == NULL)
+ if ((raw_buf = OPENSSL_zalloc(buf_len)) == NULL)
goto builtin_err;
- /* Pad the bignums with leading zeroes. */
- memset(raw_buf, 0, buf_len);
BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
bufsiz = count > 40 * 1024 ? 40 * 1024 : count;
- if ((cbuf = OPENSSL_malloc(bufsiz)) == NULL)
+ if ((cbuf = OPENSSL_zalloc(bufsiz)) == NULL)
goto err;
- if ((sbuf = OPENSSL_malloc(bufsiz)) == NULL)
+ if ((sbuf = OPENSSL_zalloc(bufsiz)) == NULL)
goto err;
- memset(cbuf, 0, bufsiz);
- memset(sbuf, 0, bufsiz);
-
c_to_s = BIO_new(BIO_s_mem());
s_to_c = BIO_new(BIO_s_mem());
if ((s_to_c == NULL) || (c_to_s == NULL)) {
X509_REQ_get_version 4951 EXIST::FUNCTION:
X509_REQ_get_subject_name 4952 EXIST::FUNCTION:
X509_CRL_up_ref 4953 EXIST::FUNCTION:
+CRYPTO_zalloc 4954 EXIST::FUNCTION:
X509_get_extension_flags 4954 EXIST::FUNCTION:
X509_get_extended_key_usage 4955 EXIST::FUNCTION:
X509_get_key_usage 4956 EXIST::FUNCTION: