diff options
| author | deraadt <> | 2014-04-21 11:12:49 +0000 |
|---|---|---|
| committer | deraadt <> | 2014-04-21 11:12:49 +0000 |
| commit | 5f744fb4f1803b9d1cdbd855ae9ee13216591f79 (patch) | |
| tree | 4a99167caf6845b449037c4bc1a9c7b9cb7f0d10 | |
| parent | 98535d12bec7fba5d9c013e3e22de9096ebd2d5a (diff) | |
| download | openbsd-5f744fb4f1803b9d1cdbd855ae9ee13216591f79.tar.gz openbsd-5f744fb4f1803b9d1cdbd855ae9ee13216591f79.tar.bz2 openbsd-5f744fb4f1803b9d1cdbd855ae9ee13216591f79.zip | |
Bring malloc/calloc/realloc sequences to modern standard
ok guenther
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/bio/bf_buff.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bf_lbuf.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bf_nbio.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_acpt.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_conn.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_dgram.c | 18 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 2 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bf_buff.c | 10 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bf_lbuf.c | 6 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bf_nbio.c | 2 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bio_lib.c | 2 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_acpt.c | 4 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_conn.c | 2 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_dgram.c | 18 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_log.c | 2 |
16 files changed, 38 insertions, 54 deletions
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c index 9dfd90c7b4..99be1a629e 100644 --- a/src/lib/libcrypto/bio/bf_buff.c +++ b/src/lib/libcrypto/bio/bf_buff.c | |||
| @@ -95,15 +95,15 @@ buffer_new(BIO *bi) | |||
| 95 | { | 95 | { |
| 96 | BIO_F_BUFFER_CTX *ctx; | 96 | BIO_F_BUFFER_CTX *ctx; |
| 97 | 97 | ||
| 98 | ctx = (BIO_F_BUFFER_CTX *)malloc(sizeof(BIO_F_BUFFER_CTX)); | 98 | ctx = malloc(sizeof(BIO_F_BUFFER_CTX)); |
| 99 | if (ctx == NULL) | 99 | if (ctx == NULL) |
| 100 | return (0); | 100 | return (0); |
| 101 | ctx->ibuf = (char *)malloc(DEFAULT_BUFFER_SIZE); | 101 | ctx->ibuf = malloc(DEFAULT_BUFFER_SIZE); |
| 102 | if (ctx->ibuf == NULL) { | 102 | if (ctx->ibuf == NULL) { |
| 103 | free(ctx); | 103 | free(ctx); |
| 104 | return (0); | 104 | return (0); |
| 105 | } | 105 | } |
| 106 | ctx->obuf = (char *)malloc(DEFAULT_BUFFER_SIZE); | 106 | ctx->obuf = malloc(DEFAULT_BUFFER_SIZE); |
| 107 | if (ctx->obuf == NULL) { | 107 | if (ctx->obuf == NULL) { |
| 108 | free(ctx->ibuf); | 108 | free(ctx->ibuf); |
| 109 | free(ctx); | 109 | free(ctx); |
| @@ -370,12 +370,12 @@ buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 370 | p1 = ctx->ibuf; | 370 | p1 = ctx->ibuf; |
| 371 | p2 = ctx->obuf; | 371 | p2 = ctx->obuf; |
| 372 | if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) { | 372 | if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) { |
| 373 | p1 = (char *)malloc((int)num); | 373 | p1 = malloc((int)num); |
| 374 | if (p1 == NULL) | 374 | if (p1 == NULL) |
| 375 | goto malloc_error; | 375 | goto malloc_error; |
| 376 | } | 376 | } |
| 377 | if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) { | 377 | if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) { |
| 378 | p2 = (char *)malloc((int)num); | 378 | p2 = malloc((int)num); |
| 379 | if (p2 == NULL) { | 379 | if (p2 == NULL) { |
| 380 | if (p1 != ctx->ibuf) | 380 | if (p1 != ctx->ibuf) |
| 381 | free(p1); | 381 | free(p1); |
diff --git a/src/lib/libcrypto/bio/bf_lbuf.c b/src/lib/libcrypto/bio/bf_lbuf.c index 7ed26ccec7..f0bd0d709e 100644 --- a/src/lib/libcrypto/bio/bf_lbuf.c +++ b/src/lib/libcrypto/bio/bf_lbuf.c | |||
| @@ -106,10 +106,10 @@ linebuffer_new(BIO *bi) | |||
| 106 | { | 106 | { |
| 107 | BIO_LINEBUFFER_CTX *ctx; | 107 | BIO_LINEBUFFER_CTX *ctx; |
| 108 | 108 | ||
| 109 | ctx = (BIO_LINEBUFFER_CTX *)malloc(sizeof(BIO_LINEBUFFER_CTX)); | 109 | ctx = malloc(sizeof(BIO_LINEBUFFER_CTX)); |
| 110 | if (ctx == NULL) | 110 | if (ctx == NULL) |
| 111 | return (0); | 111 | return (0); |
| 112 | ctx->obuf = (char *)malloc(DEFAULT_LINEBUFFER_SIZE); | 112 | ctx->obuf = malloc(DEFAULT_LINEBUFFER_SIZE); |
| 113 | if (ctx->obuf == NULL) { | 113 | if (ctx->obuf == NULL) { |
| 114 | free(ctx); | 114 | free(ctx); |
| 115 | return (0); | 115 | return (0); |
| @@ -281,7 +281,7 @@ linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 281 | obs = (int)num; | 281 | obs = (int)num; |
| 282 | p = ctx->obuf; | 282 | p = ctx->obuf; |
| 283 | if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) { | 283 | if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) { |
| 284 | p = (char *)malloc((int)num); | 284 | p = malloc((int)num); |
| 285 | if (p == NULL) | 285 | if (p == NULL) |
| 286 | goto malloc_error; | 286 | goto malloc_error; |
| 287 | } | 287 | } |
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c index 48c9781700..048e6892cc 100644 --- a/src/lib/libcrypto/bio/bf_nbio.c +++ b/src/lib/libcrypto/bio/bf_nbio.c | |||
| @@ -104,7 +104,7 @@ nbiof_new(BIO *bi) | |||
| 104 | { | 104 | { |
| 105 | NBIO_TEST *nt; | 105 | NBIO_TEST *nt; |
| 106 | 106 | ||
| 107 | if (!(nt = (NBIO_TEST *)malloc(sizeof(NBIO_TEST)))) | 107 | if (!(nt = malloc(sizeof(NBIO_TEST)))) |
| 108 | return (0); | 108 | return (0); |
| 109 | nt->lrn = -1; | 109 | nt->lrn = -1; |
| 110 | nt->lwn = -1; | 110 | nt->lwn = -1; |
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 47ab0c8a45..3deca5b744 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
| @@ -68,7 +68,7 @@ BIO_new(BIO_METHOD *method) | |||
| 68 | { | 68 | { |
| 69 | BIO *ret = NULL; | 69 | BIO *ret = NULL; |
| 70 | 70 | ||
| 71 | ret = (BIO *)malloc(sizeof(BIO)); | 71 | ret = malloc(sizeof(BIO)); |
| 72 | if (ret == NULL) { | 72 | if (ret == NULL) { |
| 73 | BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); | 73 | BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); |
| 74 | return (NULL); | 74 | return (NULL); |
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c index 4ab5856ed6..916af3cb20 100644 --- a/src/lib/libcrypto/bio/bss_acpt.c +++ b/src/lib/libcrypto/bio/bss_acpt.c | |||
| @@ -137,10 +137,8 @@ BIO_ACCEPT_new(void) | |||
| 137 | { | 137 | { |
| 138 | BIO_ACCEPT *ret; | 138 | BIO_ACCEPT *ret; |
| 139 | 139 | ||
| 140 | if ((ret = (BIO_ACCEPT *)malloc(sizeof(BIO_ACCEPT))) == NULL) | 140 | if ((ret = calloc(1, sizeof(BIO_ACCEPT))) == NULL) |
| 141 | return (NULL); | 141 | return (NULL); |
| 142 | |||
| 143 | memset(ret, 0, sizeof(BIO_ACCEPT)); | ||
| 144 | ret->accept_sock = -1; | 142 | ret->accept_sock = -1; |
| 145 | ret->bind_mode = BIO_BIND_NORMAL; | 143 | ret->bind_mode = BIO_BIND_NORMAL; |
| 146 | return (ret); | 144 | return (ret); |
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index 45815fd696..b64d7d7761 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c | |||
| @@ -295,7 +295,7 @@ BIO_CONNECT_new(void) | |||
| 295 | { | 295 | { |
| 296 | BIO_CONNECT *ret; | 296 | BIO_CONNECT *ret; |
| 297 | 297 | ||
| 298 | if ((ret = (BIO_CONNECT *)malloc(sizeof(BIO_CONNECT))) == NULL) | 298 | if ((ret = malloc(sizeof(BIO_CONNECT))) == NULL) |
| 299 | return (NULL); | 299 | return (NULL); |
| 300 | ret->state = BIO_CONN_S_BEFORE; | 300 | ret->state = BIO_CONN_S_BEFORE; |
| 301 | ret->param_hostname = NULL; | 301 | ret->param_hostname = NULL; |
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c index 79a6c2aa67..72cb19d135 100644 --- a/src/lib/libcrypto/bio/bss_dgram.c +++ b/src/lib/libcrypto/bio/bss_dgram.c | |||
| @@ -211,10 +211,9 @@ dgram_new(BIO *bi) | |||
| 211 | 211 | ||
| 212 | bi->init = 0; | 212 | bi->init = 0; |
| 213 | bi->num = 0; | 213 | bi->num = 0; |
| 214 | data = malloc(sizeof(bio_dgram_data)); | 214 | data = calloc(1, sizeof(bio_dgram_data)); |
| 215 | if (data == NULL) | 215 | if (data == NULL) |
| 216 | return 0; | 216 | return 0; |
| 217 | memset(data, 0x00, sizeof(bio_dgram_data)); | ||
| 218 | bi->ptr = data; | 217 | bi->ptr = data; |
| 219 | 218 | ||
| 220 | bi->flags = 0; | 219 | bi->flags = 0; |
| @@ -773,8 +772,7 @@ BIO_new_dgram_sctp(int fd, int close_flag) | |||
| 773 | * SCTP-AUTH has to be activated for the listening socket | 772 | * SCTP-AUTH has to be activated for the listening socket |
| 774 | * already, otherwise the connected socket won't use it. */ | 773 | * already, otherwise the connected socket won't use it. */ |
| 775 | sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); | 774 | sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); |
| 776 | authchunks = malloc(sockopt_len); | 775 | authchunks = calloc(1, sockopt_len); |
| 777 | memset(authchunks, 0, sizeof(sockopt_len)); | ||
| 778 | ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); | 776 | ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); |
| 779 | OPENSSL_assert(ret >= 0); | 777 | OPENSSL_assert(ret >= 0); |
| 780 | 778 | ||
| @@ -834,10 +832,9 @@ dgram_sctp_new(BIO *bi) | |||
| 834 | 832 | ||
| 835 | bi->init = 0; | 833 | bi->init = 0; |
| 836 | bi->num = 0; | 834 | bi->num = 0; |
| 837 | data = malloc(sizeof(bio_dgram_sctp_data)); | 835 | data = calloc(1, sizeof(bio_dgram_sctp_data)); |
| 838 | if (data == NULL) | 836 | if (data == NULL) |
| 839 | return 0; | 837 | return 0; |
| 840 | memset(data, 0x00, sizeof(bio_dgram_sctp_data)); | ||
| 841 | #ifdef SCTP_PR_SCTP_NONE | 838 | #ifdef SCTP_PR_SCTP_NONE |
| 842 | data->prinfo.pr_policy = SCTP_PR_SCTP_NONE; | 839 | data->prinfo.pr_policy = SCTP_PR_SCTP_NONE; |
| 843 | #endif | 840 | #endif |
| @@ -1055,8 +1052,7 @@ dgram_sctp_read(BIO *b, char *out, int outl) | |||
| 1055 | struct sctp_authchunks *authchunks; | 1052 | struct sctp_authchunks *authchunks; |
| 1056 | 1053 | ||
| 1057 | optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); | 1054 | optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); |
| 1058 | authchunks = malloc(optlen); | 1055 | authchunks = calloc(1, optlen); |
| 1059 | memset(authchunks, 0, sizeof(optlen)); | ||
| 1060 | ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); | 1056 | ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); |
| 1061 | OPENSSL_assert(ii >= 0); | 1057 | OPENSSL_assert(ii >= 0); |
| 1062 | 1058 | ||
| @@ -1122,8 +1118,7 @@ dgram_sctp_write(BIO *b, const char *in, int inl) | |||
| 1122 | if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { | 1118 | if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { |
| 1123 | data->saved_message.bio = b; | 1119 | data->saved_message.bio = b; |
| 1124 | data->saved_message.length = inl; | 1120 | data->saved_message.length = inl; |
| 1125 | data->saved_message.data = malloc(inl); | 1121 | data->saved_message.data = calloc(1, inl); |
| 1126 | memcpy(data->saved_message.data, in, inl); | ||
| 1127 | return inl; | 1122 | return inl; |
| 1128 | } | 1123 | } |
| 1129 | 1124 | ||
| @@ -1250,8 +1245,7 @@ dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 1250 | 1245 | ||
| 1251 | /* Add new key */ | 1246 | /* Add new key */ |
| 1252 | sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t); | 1247 | sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t); |
| 1253 | authkey = malloc(sockopt_len); | 1248 | authkey = calloc(1, sockopt_len); |
| 1254 | memset(authkey, 0x00, sockopt_len); | ||
| 1255 | authkey->sca_keynumber = authkeyid.scact_keynumber + 1; | 1249 | authkey->sca_keynumber = authkeyid.scact_keynumber + 1; |
| 1256 | #ifndef __FreeBSD__ | 1250 | #ifndef __FreeBSD__ |
| 1257 | /* This field is missing in FreeBSD 8.2 and earlier, | 1251 | /* This field is missing in FreeBSD 8.2 and earlier, |
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 342176f82e..6aa2d8b0a4 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c | |||
| @@ -157,7 +157,7 @@ slg_write(BIO *b, const char *in, int inl) | |||
| 157 | { 0, "", LOG_ERR } /* The default */ | 157 | { 0, "", LOG_ERR } /* The default */ |
| 158 | }; | 158 | }; |
| 159 | 159 | ||
| 160 | if ((buf = (char *)malloc(inl + 1)) == NULL) { | 160 | if ((buf = malloc(inl + 1)) == NULL) { |
| 161 | return (0); | 161 | return (0); |
| 162 | } | 162 | } |
| 163 | strlcpy(buf, in, inl + 1); | 163 | strlcpy(buf, in, inl + 1); |
diff --git a/src/lib/libssl/src/crypto/bio/bf_buff.c b/src/lib/libssl/src/crypto/bio/bf_buff.c index 9dfd90c7b4..99be1a629e 100644 --- a/src/lib/libssl/src/crypto/bio/bf_buff.c +++ b/src/lib/libssl/src/crypto/bio/bf_buff.c | |||
| @@ -95,15 +95,15 @@ buffer_new(BIO *bi) | |||
| 95 | { | 95 | { |
| 96 | BIO_F_BUFFER_CTX *ctx; | 96 | BIO_F_BUFFER_CTX *ctx; |
| 97 | 97 | ||
| 98 | ctx = (BIO_F_BUFFER_CTX *)malloc(sizeof(BIO_F_BUFFER_CTX)); | 98 | ctx = malloc(sizeof(BIO_F_BUFFER_CTX)); |
| 99 | if (ctx == NULL) | 99 | if (ctx == NULL) |
| 100 | return (0); | 100 | return (0); |
| 101 | ctx->ibuf = (char *)malloc(DEFAULT_BUFFER_SIZE); | 101 | ctx->ibuf = malloc(DEFAULT_BUFFER_SIZE); |
| 102 | if (ctx->ibuf == NULL) { | 102 | if (ctx->ibuf == NULL) { |
| 103 | free(ctx); | 103 | free(ctx); |
| 104 | return (0); | 104 | return (0); |
| 105 | } | 105 | } |
| 106 | ctx->obuf = (char *)malloc(DEFAULT_BUFFER_SIZE); | 106 | ctx->obuf = malloc(DEFAULT_BUFFER_SIZE); |
| 107 | if (ctx->obuf == NULL) { | 107 | if (ctx->obuf == NULL) { |
| 108 | free(ctx->ibuf); | 108 | free(ctx->ibuf); |
| 109 | free(ctx); | 109 | free(ctx); |
| @@ -370,12 +370,12 @@ buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 370 | p1 = ctx->ibuf; | 370 | p1 = ctx->ibuf; |
| 371 | p2 = ctx->obuf; | 371 | p2 = ctx->obuf; |
| 372 | if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) { | 372 | if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) { |
| 373 | p1 = (char *)malloc((int)num); | 373 | p1 = malloc((int)num); |
| 374 | if (p1 == NULL) | 374 | if (p1 == NULL) |
| 375 | goto malloc_error; | 375 | goto malloc_error; |
| 376 | } | 376 | } |
| 377 | if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) { | 377 | if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) { |
| 378 | p2 = (char *)malloc((int)num); | 378 | p2 = malloc((int)num); |
| 379 | if (p2 == NULL) { | 379 | if (p2 == NULL) { |
| 380 | if (p1 != ctx->ibuf) | 380 | if (p1 != ctx->ibuf) |
| 381 | free(p1); | 381 | free(p1); |
diff --git a/src/lib/libssl/src/crypto/bio/bf_lbuf.c b/src/lib/libssl/src/crypto/bio/bf_lbuf.c index 7ed26ccec7..f0bd0d709e 100644 --- a/src/lib/libssl/src/crypto/bio/bf_lbuf.c +++ b/src/lib/libssl/src/crypto/bio/bf_lbuf.c | |||
| @@ -106,10 +106,10 @@ linebuffer_new(BIO *bi) | |||
| 106 | { | 106 | { |
| 107 | BIO_LINEBUFFER_CTX *ctx; | 107 | BIO_LINEBUFFER_CTX *ctx; |
| 108 | 108 | ||
| 109 | ctx = (BIO_LINEBUFFER_CTX *)malloc(sizeof(BIO_LINEBUFFER_CTX)); | 109 | ctx = malloc(sizeof(BIO_LINEBUFFER_CTX)); |
| 110 | if (ctx == NULL) | 110 | if (ctx == NULL) |
| 111 | return (0); | 111 | return (0); |
| 112 | ctx->obuf = (char *)malloc(DEFAULT_LINEBUFFER_SIZE); | 112 | ctx->obuf = malloc(DEFAULT_LINEBUFFER_SIZE); |
| 113 | if (ctx->obuf == NULL) { | 113 | if (ctx->obuf == NULL) { |
| 114 | free(ctx); | 114 | free(ctx); |
| 115 | return (0); | 115 | return (0); |
| @@ -281,7 +281,7 @@ linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 281 | obs = (int)num; | 281 | obs = (int)num; |
| 282 | p = ctx->obuf; | 282 | p = ctx->obuf; |
| 283 | if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) { | 283 | if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) { |
| 284 | p = (char *)malloc((int)num); | 284 | p = malloc((int)num); |
| 285 | if (p == NULL) | 285 | if (p == NULL) |
| 286 | goto malloc_error; | 286 | goto malloc_error; |
| 287 | } | 287 | } |
diff --git a/src/lib/libssl/src/crypto/bio/bf_nbio.c b/src/lib/libssl/src/crypto/bio/bf_nbio.c index 48c9781700..048e6892cc 100644 --- a/src/lib/libssl/src/crypto/bio/bf_nbio.c +++ b/src/lib/libssl/src/crypto/bio/bf_nbio.c | |||
| @@ -104,7 +104,7 @@ nbiof_new(BIO *bi) | |||
| 104 | { | 104 | { |
| 105 | NBIO_TEST *nt; | 105 | NBIO_TEST *nt; |
| 106 | 106 | ||
| 107 | if (!(nt = (NBIO_TEST *)malloc(sizeof(NBIO_TEST)))) | 107 | if (!(nt = malloc(sizeof(NBIO_TEST)))) |
| 108 | return (0); | 108 | return (0); |
| 109 | nt->lrn = -1; | 109 | nt->lrn = -1; |
| 110 | nt->lwn = -1; | 110 | nt->lwn = -1; |
diff --git a/src/lib/libssl/src/crypto/bio/bio_lib.c b/src/lib/libssl/src/crypto/bio/bio_lib.c index 47ab0c8a45..3deca5b744 100644 --- a/src/lib/libssl/src/crypto/bio/bio_lib.c +++ b/src/lib/libssl/src/crypto/bio/bio_lib.c | |||
| @@ -68,7 +68,7 @@ BIO_new(BIO_METHOD *method) | |||
| 68 | { | 68 | { |
| 69 | BIO *ret = NULL; | 69 | BIO *ret = NULL; |
| 70 | 70 | ||
| 71 | ret = (BIO *)malloc(sizeof(BIO)); | 71 | ret = malloc(sizeof(BIO)); |
| 72 | if (ret == NULL) { | 72 | if (ret == NULL) { |
| 73 | BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); | 73 | BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); |
| 74 | return (NULL); | 74 | return (NULL); |
diff --git a/src/lib/libssl/src/crypto/bio/bss_acpt.c b/src/lib/libssl/src/crypto/bio/bss_acpt.c index 4ab5856ed6..916af3cb20 100644 --- a/src/lib/libssl/src/crypto/bio/bss_acpt.c +++ b/src/lib/libssl/src/crypto/bio/bss_acpt.c | |||
| @@ -137,10 +137,8 @@ BIO_ACCEPT_new(void) | |||
| 137 | { | 137 | { |
| 138 | BIO_ACCEPT *ret; | 138 | BIO_ACCEPT *ret; |
| 139 | 139 | ||
| 140 | if ((ret = (BIO_ACCEPT *)malloc(sizeof(BIO_ACCEPT))) == NULL) | 140 | if ((ret = calloc(1, sizeof(BIO_ACCEPT))) == NULL) |
| 141 | return (NULL); | 141 | return (NULL); |
| 142 | |||
| 143 | memset(ret, 0, sizeof(BIO_ACCEPT)); | ||
| 144 | ret->accept_sock = -1; | 142 | ret->accept_sock = -1; |
| 145 | ret->bind_mode = BIO_BIND_NORMAL; | 143 | ret->bind_mode = BIO_BIND_NORMAL; |
| 146 | return (ret); | 144 | return (ret); |
diff --git a/src/lib/libssl/src/crypto/bio/bss_conn.c b/src/lib/libssl/src/crypto/bio/bss_conn.c index 45815fd696..b64d7d7761 100644 --- a/src/lib/libssl/src/crypto/bio/bss_conn.c +++ b/src/lib/libssl/src/crypto/bio/bss_conn.c | |||
| @@ -295,7 +295,7 @@ BIO_CONNECT_new(void) | |||
| 295 | { | 295 | { |
| 296 | BIO_CONNECT *ret; | 296 | BIO_CONNECT *ret; |
| 297 | 297 | ||
| 298 | if ((ret = (BIO_CONNECT *)malloc(sizeof(BIO_CONNECT))) == NULL) | 298 | if ((ret = malloc(sizeof(BIO_CONNECT))) == NULL) |
| 299 | return (NULL); | 299 | return (NULL); |
| 300 | ret->state = BIO_CONN_S_BEFORE; | 300 | ret->state = BIO_CONN_S_BEFORE; |
| 301 | ret->param_hostname = NULL; | 301 | ret->param_hostname = NULL; |
diff --git a/src/lib/libssl/src/crypto/bio/bss_dgram.c b/src/lib/libssl/src/crypto/bio/bss_dgram.c index 79a6c2aa67..72cb19d135 100644 --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c | |||
| @@ -211,10 +211,9 @@ dgram_new(BIO *bi) | |||
| 211 | 211 | ||
| 212 | bi->init = 0; | 212 | bi->init = 0; |
| 213 | bi->num = 0; | 213 | bi->num = 0; |
| 214 | data = malloc(sizeof(bio_dgram_data)); | 214 | data = calloc(1, sizeof(bio_dgram_data)); |
| 215 | if (data == NULL) | 215 | if (data == NULL) |
| 216 | return 0; | 216 | return 0; |
| 217 | memset(data, 0x00, sizeof(bio_dgram_data)); | ||
| 218 | bi->ptr = data; | 217 | bi->ptr = data; |
| 219 | 218 | ||
| 220 | bi->flags = 0; | 219 | bi->flags = 0; |
| @@ -773,8 +772,7 @@ BIO_new_dgram_sctp(int fd, int close_flag) | |||
| 773 | * SCTP-AUTH has to be activated for the listening socket | 772 | * SCTP-AUTH has to be activated for the listening socket |
| 774 | * already, otherwise the connected socket won't use it. */ | 773 | * already, otherwise the connected socket won't use it. */ |
| 775 | sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); | 774 | sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); |
| 776 | authchunks = malloc(sockopt_len); | 775 | authchunks = calloc(1, sockopt_len); |
| 777 | memset(authchunks, 0, sizeof(sockopt_len)); | ||
| 778 | ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); | 776 | ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); |
| 779 | OPENSSL_assert(ret >= 0); | 777 | OPENSSL_assert(ret >= 0); |
| 780 | 778 | ||
| @@ -834,10 +832,9 @@ dgram_sctp_new(BIO *bi) | |||
| 834 | 832 | ||
| 835 | bi->init = 0; | 833 | bi->init = 0; |
| 836 | bi->num = 0; | 834 | bi->num = 0; |
| 837 | data = malloc(sizeof(bio_dgram_sctp_data)); | 835 | data = calloc(1, sizeof(bio_dgram_sctp_data)); |
| 838 | if (data == NULL) | 836 | if (data == NULL) |
| 839 | return 0; | 837 | return 0; |
| 840 | memset(data, 0x00, sizeof(bio_dgram_sctp_data)); | ||
| 841 | #ifdef SCTP_PR_SCTP_NONE | 838 | #ifdef SCTP_PR_SCTP_NONE |
| 842 | data->prinfo.pr_policy = SCTP_PR_SCTP_NONE; | 839 | data->prinfo.pr_policy = SCTP_PR_SCTP_NONE; |
| 843 | #endif | 840 | #endif |
| @@ -1055,8 +1052,7 @@ dgram_sctp_read(BIO *b, char *out, int outl) | |||
| 1055 | struct sctp_authchunks *authchunks; | 1052 | struct sctp_authchunks *authchunks; |
| 1056 | 1053 | ||
| 1057 | optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); | 1054 | optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); |
| 1058 | authchunks = malloc(optlen); | 1055 | authchunks = calloc(1, optlen); |
| 1059 | memset(authchunks, 0, sizeof(optlen)); | ||
| 1060 | ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); | 1056 | ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); |
| 1061 | OPENSSL_assert(ii >= 0); | 1057 | OPENSSL_assert(ii >= 0); |
| 1062 | 1058 | ||
| @@ -1122,8 +1118,7 @@ dgram_sctp_write(BIO *b, const char *in, int inl) | |||
| 1122 | if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { | 1118 | if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { |
| 1123 | data->saved_message.bio = b; | 1119 | data->saved_message.bio = b; |
| 1124 | data->saved_message.length = inl; | 1120 | data->saved_message.length = inl; |
| 1125 | data->saved_message.data = malloc(inl); | 1121 | data->saved_message.data = calloc(1, inl); |
| 1126 | memcpy(data->saved_message.data, in, inl); | ||
| 1127 | return inl; | 1122 | return inl; |
| 1128 | } | 1123 | } |
| 1129 | 1124 | ||
| @@ -1250,8 +1245,7 @@ dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 1250 | 1245 | ||
| 1251 | /* Add new key */ | 1246 | /* Add new key */ |
| 1252 | sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t); | 1247 | sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t); |
| 1253 | authkey = malloc(sockopt_len); | 1248 | authkey = calloc(1, sockopt_len); |
| 1254 | memset(authkey, 0x00, sockopt_len); | ||
| 1255 | authkey->sca_keynumber = authkeyid.scact_keynumber + 1; | 1249 | authkey->sca_keynumber = authkeyid.scact_keynumber + 1; |
| 1256 | #ifndef __FreeBSD__ | 1250 | #ifndef __FreeBSD__ |
| 1257 | /* This field is missing in FreeBSD 8.2 and earlier, | 1251 | /* This field is missing in FreeBSD 8.2 and earlier, |
diff --git a/src/lib/libssl/src/crypto/bio/bss_log.c b/src/lib/libssl/src/crypto/bio/bss_log.c index 342176f82e..6aa2d8b0a4 100644 --- a/src/lib/libssl/src/crypto/bio/bss_log.c +++ b/src/lib/libssl/src/crypto/bio/bss_log.c | |||
| @@ -157,7 +157,7 @@ slg_write(BIO *b, const char *in, int inl) | |||
| 157 | { 0, "", LOG_ERR } /* The default */ | 157 | { 0, "", LOG_ERR } /* The default */ |
| 158 | }; | 158 | }; |
| 159 | 159 | ||
| 160 | if ((buf = (char *)malloc(inl + 1)) == NULL) { | 160 | if ((buf = malloc(inl + 1)) == NULL) { |
| 161 | return (0); | 161 | return (0); |
| 162 | } | 162 | } |
| 163 | strlcpy(buf, in, inl + 1); | 163 | strlcpy(buf, in, inl + 1); |
