{
BIO_F_BUFFER_CTX *ctx;
- ctx = (BIO_F_BUFFER_CTX *)malloc(sizeof(BIO_F_BUFFER_CTX));
+ ctx = malloc(sizeof(BIO_F_BUFFER_CTX));
if (ctx == NULL)
return (0);
- ctx->ibuf = (char *)malloc(DEFAULT_BUFFER_SIZE);
+ ctx->ibuf = malloc(DEFAULT_BUFFER_SIZE);
if (ctx->ibuf == NULL) {
free(ctx);
return (0);
}
- ctx->obuf = (char *)malloc(DEFAULT_BUFFER_SIZE);
+ ctx->obuf = malloc(DEFAULT_BUFFER_SIZE);
if (ctx->obuf == NULL) {
free(ctx->ibuf);
free(ctx);
p1 = ctx->ibuf;
p2 = ctx->obuf;
if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) {
- p1 = (char *)malloc((int)num);
+ p1 = malloc((int)num);
if (p1 == NULL)
goto malloc_error;
}
if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) {
- p2 = (char *)malloc((int)num);
+ p2 = malloc((int)num);
if (p2 == NULL) {
if (p1 != ctx->ibuf)
free(p1);
{
BIO_LINEBUFFER_CTX *ctx;
- ctx = (BIO_LINEBUFFER_CTX *)malloc(sizeof(BIO_LINEBUFFER_CTX));
+ ctx = malloc(sizeof(BIO_LINEBUFFER_CTX));
if (ctx == NULL)
return (0);
- ctx->obuf = (char *)malloc(DEFAULT_LINEBUFFER_SIZE);
+ ctx->obuf = malloc(DEFAULT_LINEBUFFER_SIZE);
if (ctx->obuf == NULL) {
free(ctx);
return (0);
obs = (int)num;
p = ctx->obuf;
if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) {
- p = (char *)malloc((int)num);
+ p = malloc((int)num);
if (p == NULL)
goto malloc_error;
}
{
NBIO_TEST *nt;
- if (!(nt = (NBIO_TEST *)malloc(sizeof(NBIO_TEST))))
+ if (!(nt = malloc(sizeof(NBIO_TEST))))
return (0);
nt->lrn = -1;
nt->lwn = -1;
{
BIO *ret = NULL;
- ret = (BIO *)malloc(sizeof(BIO));
+ ret = malloc(sizeof(BIO));
if (ret == NULL) {
BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
{
BIO_ACCEPT *ret;
- if ((ret = (BIO_ACCEPT *)malloc(sizeof(BIO_ACCEPT))) == NULL)
+ if ((ret = calloc(1, sizeof(BIO_ACCEPT))) == NULL)
return (NULL);
-
- memset(ret, 0, sizeof(BIO_ACCEPT));
ret->accept_sock = -1;
ret->bind_mode = BIO_BIND_NORMAL;
return (ret);
{
BIO_CONNECT *ret;
- if ((ret = (BIO_CONNECT *)malloc(sizeof(BIO_CONNECT))) == NULL)
+ if ((ret = malloc(sizeof(BIO_CONNECT))) == NULL)
return (NULL);
ret->state = BIO_CONN_S_BEFORE;
ret->param_hostname = NULL;
bi->init = 0;
bi->num = 0;
- data = malloc(sizeof(bio_dgram_data));
+ data = calloc(1, sizeof(bio_dgram_data));
if (data == NULL)
return 0;
- memset(data, 0x00, sizeof(bio_dgram_data));
bi->ptr = data;
bi->flags = 0;
* SCTP-AUTH has to be activated for the listening socket
* already, otherwise the connected socket won't use it. */
sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t));
- authchunks = malloc(sockopt_len);
- memset(authchunks, 0, sizeof(sockopt_len));
+ authchunks = calloc(1, sockopt_len);
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
OPENSSL_assert(ret >= 0);
bi->init = 0;
bi->num = 0;
- data = malloc(sizeof(bio_dgram_sctp_data));
+ data = calloc(1, sizeof(bio_dgram_sctp_data));
if (data == NULL)
return 0;
- memset(data, 0x00, sizeof(bio_dgram_sctp_data));
#ifdef SCTP_PR_SCTP_NONE
data->prinfo.pr_policy = SCTP_PR_SCTP_NONE;
#endif
struct sctp_authchunks *authchunks;
optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t));
- authchunks = malloc(optlen);
- memset(authchunks, 0, sizeof(optlen));
+ authchunks = calloc(1, optlen);
ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
OPENSSL_assert(ii >= 0);
if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) {
data->saved_message.bio = b;
data->saved_message.length = inl;
- data->saved_message.data = malloc(inl);
- memcpy(data->saved_message.data, in, inl);
+ data->saved_message.data = calloc(1, inl);
return inl;
}
/* Add new key */
sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t);
- authkey = malloc(sockopt_len);
- memset(authkey, 0x00, sockopt_len);
+ authkey = calloc(1, sockopt_len);
authkey->sca_keynumber = authkeyid.scact_keynumber + 1;
#ifndef __FreeBSD__
/* This field is missing in FreeBSD 8.2 and earlier,
{ 0, "", LOG_ERR } /* The default */
};
- if ((buf = (char *)malloc(inl + 1)) == NULL) {
+ if ((buf = malloc(inl + 1)) == NULL) {
return (0);
}
strlcpy(buf, in, inl + 1);
{
BIO_F_BUFFER_CTX *ctx;
- ctx = (BIO_F_BUFFER_CTX *)malloc(sizeof(BIO_F_BUFFER_CTX));
+ ctx = malloc(sizeof(BIO_F_BUFFER_CTX));
if (ctx == NULL)
return (0);
- ctx->ibuf = (char *)malloc(DEFAULT_BUFFER_SIZE);
+ ctx->ibuf = malloc(DEFAULT_BUFFER_SIZE);
if (ctx->ibuf == NULL) {
free(ctx);
return (0);
}
- ctx->obuf = (char *)malloc(DEFAULT_BUFFER_SIZE);
+ ctx->obuf = malloc(DEFAULT_BUFFER_SIZE);
if (ctx->obuf == NULL) {
free(ctx->ibuf);
free(ctx);
p1 = ctx->ibuf;
p2 = ctx->obuf;
if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) {
- p1 = (char *)malloc((int)num);
+ p1 = malloc((int)num);
if (p1 == NULL)
goto malloc_error;
}
if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) {
- p2 = (char *)malloc((int)num);
+ p2 = malloc((int)num);
if (p2 == NULL) {
if (p1 != ctx->ibuf)
free(p1);
{
BIO_LINEBUFFER_CTX *ctx;
- ctx = (BIO_LINEBUFFER_CTX *)malloc(sizeof(BIO_LINEBUFFER_CTX));
+ ctx = malloc(sizeof(BIO_LINEBUFFER_CTX));
if (ctx == NULL)
return (0);
- ctx->obuf = (char *)malloc(DEFAULT_LINEBUFFER_SIZE);
+ ctx->obuf = malloc(DEFAULT_LINEBUFFER_SIZE);
if (ctx->obuf == NULL) {
free(ctx);
return (0);
obs = (int)num;
p = ctx->obuf;
if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) {
- p = (char *)malloc((int)num);
+ p = malloc((int)num);
if (p == NULL)
goto malloc_error;
}
{
NBIO_TEST *nt;
- if (!(nt = (NBIO_TEST *)malloc(sizeof(NBIO_TEST))))
+ if (!(nt = malloc(sizeof(NBIO_TEST))))
return (0);
nt->lrn = -1;
nt->lwn = -1;
{
BIO *ret = NULL;
- ret = (BIO *)malloc(sizeof(BIO));
+ ret = malloc(sizeof(BIO));
if (ret == NULL) {
BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
return (NULL);
{
BIO_ACCEPT *ret;
- if ((ret = (BIO_ACCEPT *)malloc(sizeof(BIO_ACCEPT))) == NULL)
+ if ((ret = calloc(1, sizeof(BIO_ACCEPT))) == NULL)
return (NULL);
-
- memset(ret, 0, sizeof(BIO_ACCEPT));
ret->accept_sock = -1;
ret->bind_mode = BIO_BIND_NORMAL;
return (ret);
{
BIO_CONNECT *ret;
- if ((ret = (BIO_CONNECT *)malloc(sizeof(BIO_CONNECT))) == NULL)
+ if ((ret = malloc(sizeof(BIO_CONNECT))) == NULL)
return (NULL);
ret->state = BIO_CONN_S_BEFORE;
ret->param_hostname = NULL;
bi->init = 0;
bi->num = 0;
- data = malloc(sizeof(bio_dgram_data));
+ data = calloc(1, sizeof(bio_dgram_data));
if (data == NULL)
return 0;
- memset(data, 0x00, sizeof(bio_dgram_data));
bi->ptr = data;
bi->flags = 0;
* SCTP-AUTH has to be activated for the listening socket
* already, otherwise the connected socket won't use it. */
sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t));
- authchunks = malloc(sockopt_len);
- memset(authchunks, 0, sizeof(sockopt_len));
+ authchunks = calloc(1, sockopt_len);
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
OPENSSL_assert(ret >= 0);
bi->init = 0;
bi->num = 0;
- data = malloc(sizeof(bio_dgram_sctp_data));
+ data = calloc(1, sizeof(bio_dgram_sctp_data));
if (data == NULL)
return 0;
- memset(data, 0x00, sizeof(bio_dgram_sctp_data));
#ifdef SCTP_PR_SCTP_NONE
data->prinfo.pr_policy = SCTP_PR_SCTP_NONE;
#endif
struct sctp_authchunks *authchunks;
optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t));
- authchunks = malloc(optlen);
- memset(authchunks, 0, sizeof(optlen));
+ authchunks = calloc(1, optlen);
ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
OPENSSL_assert(ii >= 0);
if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) {
data->saved_message.bio = b;
data->saved_message.length = inl;
- data->saved_message.data = malloc(inl);
- memcpy(data->saved_message.data, in, inl);
+ data->saved_message.data = calloc(1, inl);
return inl;
}
/* Add new key */
sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t);
- authkey = malloc(sockopt_len);
- memset(authkey, 0x00, sockopt_len);
+ authkey = calloc(1, sockopt_len);
authkey->sca_keynumber = authkeyid.scact_keynumber + 1;
#ifndef __FreeBSD__
/* This field is missing in FreeBSD 8.2 and earlier,
{ 0, "", LOG_ERR } /* The default */
};
- if ((buf = (char *)malloc(inl + 1)) == NULL) {
+ if ((buf = malloc(inl + 1)) == NULL) {
return (0);
}
strlcpy(buf, in, inl + 1);