diff options
32 files changed, 46 insertions, 96 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c index c578ce6279..f3cce8b536 100644 --- a/src/lib/libcrypto/asn1/a_bitstr.c +++ b/src/lib/libcrypto/asn1/a_bitstr.c | |||
@@ -153,7 +153,7 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) | |||
153 | 153 | ||
154 | if (len-- > 1) /* using one because of the bits left byte */ | 154 | if (len-- > 1) /* using one because of the bits left byte */ |
155 | { | 155 | { |
156 | s = (unsigned char *)malloc((int)len); | 156 | s = malloc((int)len); |
157 | if (s == NULL) { | 157 | if (s == NULL) { |
158 | i = ERR_R_MALLOC_FAILURE; | 158 | i = ERR_R_MALLOC_FAILURE; |
159 | goto err; | 159 | goto err; |
@@ -203,11 +203,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) | |||
203 | if ((a->length < (w + 1)) || (a->data == NULL)) { | 203 | if ((a->length < (w + 1)) || (a->data == NULL)) { |
204 | if (!value) | 204 | if (!value) |
205 | return(1); /* Don't need to set */ | 205 | return(1); /* Don't need to set */ |
206 | if (a->data == NULL) | 206 | c = OPENSSL_realloc_clean(a->data, a->length, w + 1); |
207 | c = (unsigned char *)malloc(w + 1); | ||
208 | else | ||
209 | c = (unsigned char *)OPENSSL_realloc_clean(a->data, | ||
210 | a->length, w + 1); | ||
211 | if (c == NULL) { | 207 | if (c == NULL) { |
212 | ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); | 208 | ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); |
213 | return 0; | 209 | return 0; |
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c index 30647c97b5..34ed7b7db2 100644 --- a/src/lib/libcrypto/asn1/a_bytes.c +++ b/src/lib/libcrypto/asn1/a_bytes.c | |||
@@ -99,7 +99,7 @@ d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
99 | ret = (*a); | 99 | ret = (*a); |
100 | 100 | ||
101 | if (len != 0) { | 101 | if (len != 0) { |
102 | s = (unsigned char *)malloc((int)len + 1); | 102 | s = malloc((int)len + 1); |
103 | if (s == NULL) { | 103 | if (s == NULL) { |
104 | i = ERR_R_MALLOC_FAILURE; | 104 | i = ERR_R_MALLOC_FAILURE; |
105 | goto err; | 105 | goto err; |
@@ -205,7 +205,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
205 | if ((ret->length < len) || (ret->data == NULL)) { | 205 | if ((ret->length < len) || (ret->data == NULL)) { |
206 | if (ret->data != NULL) | 206 | if (ret->data != NULL) |
207 | free(ret->data); | 207 | free(ret->data); |
208 | s = (unsigned char *)malloc((int)len + 1); | 208 | s = malloc(len + 1); |
209 | if (s == NULL) { | 209 | if (s == NULL) { |
210 | i = ERR_R_MALLOC_FAILURE; | 210 | i = ERR_R_MALLOC_FAILURE; |
211 | goto err; | 211 | goto err; |
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index 5e6f7589cf..aa28c7c8d7 100644 --- a/src/lib/libcrypto/asn1/a_enum.c +++ b/src/lib/libcrypto/asn1/a_enum.c | |||
@@ -78,8 +78,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) | |||
78 | if (a->length < (int)(sizeof(long) + 1)) { | 78 | if (a->length < (int)(sizeof(long) + 1)) { |
79 | if (a->data != NULL) | 79 | if (a->data != NULL) |
80 | free(a->data); | 80 | free(a->data); |
81 | if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL) | 81 | a->data = calloc(1, sizeof(long) + 1); |
82 | memset((char *)a->data, 0, sizeof(long) + 1); | ||
83 | } | 82 | } |
84 | if (a->data == NULL) { | 83 | if (a->data == NULL) { |
85 | ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); | 84 | ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c index 082ba1b3a8..007e612b4a 100644 --- a/src/lib/libcrypto/asn1/a_i2d_fp.c +++ b/src/lib/libcrypto/asn1/a_i2d_fp.c | |||
@@ -89,7 +89,7 @@ ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) | |||
89 | int i, j = 0, n, ret = 1; | 89 | int i, j = 0, n, ret = 1; |
90 | 90 | ||
91 | n = i2d(x, NULL); | 91 | n = i2d(x, NULL); |
92 | b = (char *)malloc(n); | 92 | b = malloc(n); |
93 | if (b == NULL) { | 93 | if (b == NULL) { |
94 | ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); | 94 | ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); |
95 | return (0); | 95 | return (0); |
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 05776f572c..0559cce384 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
@@ -205,7 +205,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) | |||
205 | 205 | ||
206 | /* We must malloc stuff, even for 0 bytes otherwise it | 206 | /* We must malloc stuff, even for 0 bytes otherwise it |
207 | * signifies a missing NULL parameter. */ | 207 | * signifies a missing NULL parameter. */ |
208 | s = (unsigned char *)malloc((int)len + 1); | 208 | s = malloc((int)len + 1); |
209 | if (s == NULL) { | 209 | if (s == NULL) { |
210 | i = ERR_R_MALLOC_FAILURE; | 210 | i = ERR_R_MALLOC_FAILURE; |
211 | goto err; | 211 | goto err; |
@@ -309,7 +309,7 @@ d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length) | |||
309 | 309 | ||
310 | /* We must malloc stuff, even for 0 bytes otherwise it | 310 | /* We must malloc stuff, even for 0 bytes otherwise it |
311 | * signifies a missing NULL parameter. */ | 311 | * signifies a missing NULL parameter. */ |
312 | s = (unsigned char *)malloc((int)len + 1); | 312 | s = malloc((int)len + 1); |
313 | if (s == NULL) { | 313 | if (s == NULL) { |
314 | i = ERR_R_MALLOC_FAILURE; | 314 | i = ERR_R_MALLOC_FAILURE; |
315 | goto err; | 315 | goto err; |
@@ -352,8 +352,7 @@ ASN1_INTEGER_set(ASN1_INTEGER *a, long v) | |||
352 | if (a->length < (int)(sizeof(long) + 1)) { | 352 | if (a->length < (int)(sizeof(long) + 1)) { |
353 | if (a->data != NULL) | 353 | if (a->data != NULL) |
354 | free(a->data); | 354 | free(a->data); |
355 | if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL) | 355 | a->data = calloc(1, sizeof(long) + 1); |
356 | memset((char *)a->data, 0, sizeof(long) + 1); | ||
357 | } | 356 | } |
358 | if (a->data == NULL) { | 357 | if (a->data == NULL) { |
359 | ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); | 358 | ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c index 93c755228a..f86d54f527 100644 --- a/src/lib/libcrypto/asn1/a_object.c +++ b/src/lib/libcrypto/asn1/a_object.c | |||
@@ -312,7 +312,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) | |||
312 | ret->length = 0; | 312 | ret->length = 0; |
313 | if (data != NULL) | 313 | if (data != NULL) |
314 | free(data); | 314 | free(data); |
315 | data = (unsigned char *)malloc(len ? (int)len : 1); | 315 | data = malloc(len ? (int)len : 1); |
316 | if (data == NULL) { | 316 | if (data == NULL) { |
317 | i = ERR_R_MALLOC_FAILURE; | 317 | i = ERR_R_MALLOC_FAILURE; |
318 | goto err; | 318 | goto err; |
@@ -345,7 +345,7 @@ ASN1_OBJECT_new(void) | |||
345 | { | 345 | { |
346 | ASN1_OBJECT *ret; | 346 | ASN1_OBJECT *ret; |
347 | 347 | ||
348 | ret = (ASN1_OBJECT *)malloc(sizeof(ASN1_OBJECT)); | 348 | ret = malloc(sizeof(ASN1_OBJECT)); |
349 | if (ret == NULL) { | 349 | if (ret == NULL) { |
350 | ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); | 350 | ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); |
351 | return (NULL); | 351 | return (NULL); |
diff --git a/src/lib/libcrypto/asn1/ameth_lib.c b/src/lib/libcrypto/asn1/ameth_lib.c index 63ff18edae..8652e938bd 100644 --- a/src/lib/libcrypto/asn1/ameth_lib.c +++ b/src/lib/libcrypto/asn1/ameth_lib.c | |||
@@ -287,12 +287,10 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) | |||
287 | { | 287 | { |
288 | EVP_PKEY_ASN1_METHOD *ameth; | 288 | EVP_PKEY_ASN1_METHOD *ameth; |
289 | 289 | ||
290 | ameth = malloc(sizeof(EVP_PKEY_ASN1_METHOD)); | 290 | ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD)); |
291 | if (!ameth) | 291 | if (!ameth) |
292 | return NULL; | 292 | return NULL; |
293 | 293 | ||
294 | memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD)); | ||
295 | |||
296 | ameth->pkey_id = id; | 294 | ameth->pkey_id = id; |
297 | ameth->pkey_base_id = id; | 295 | ameth->pkey_base_id = id; |
298 | ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; | 296 | ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; |
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c index f3b2f0480f..4d4368aefe 100644 --- a/src/lib/libcrypto/asn1/asn1_lib.c +++ b/src/lib/libcrypto/asn1/asn1_lib.c | |||
@@ -418,7 +418,7 @@ ASN1_STRING_type_new(int type) | |||
418 | { | 418 | { |
419 | ASN1_STRING *ret; | 419 | ASN1_STRING *ret; |
420 | 420 | ||
421 | ret = (ASN1_STRING *)malloc(sizeof(ASN1_STRING)); | 421 | ret = malloc(sizeof(ASN1_STRING)); |
422 | if (ret == NULL) { | 422 | if (ret == NULL) { |
423 | ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); | 423 | ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); |
424 | return (NULL); | 424 | return (NULL); |
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c index 890557578d..248ea114e8 100644 --- a/src/lib/libcrypto/asn1/asn_mime.c +++ b/src/lib/libcrypto/asn1/asn_mime.c | |||
@@ -850,7 +850,7 @@ mime_hdr_new(char *name, char *value) | |||
850 | } | 850 | } |
851 | } | 851 | } |
852 | } else tmpval = NULL; | 852 | } else tmpval = NULL; |
853 | mhdr = (MIME_HEADER *)malloc(sizeof(MIME_HEADER)); | 853 | mhdr = malloc(sizeof(MIME_HEADER)); |
854 | if (!mhdr) { | 854 | if (!mhdr) { |
855 | OPENSSL_free(tmpname); | 855 | OPENSSL_free(tmpname); |
856 | return NULL; | 856 | return NULL; |
@@ -891,7 +891,7 @@ mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) | |||
891 | } else | 891 | } else |
892 | tmpval = NULL; | 892 | tmpval = NULL; |
893 | /* Parameter values are case sensitive so leave as is */ | 893 | /* Parameter values are case sensitive so leave as is */ |
894 | mparam = (MIME_PARAM *) malloc(sizeof(MIME_PARAM)); | 894 | mparam = malloc(sizeof(MIME_PARAM)); |
895 | if (!mparam) | 895 | if (!mparam) |
896 | return 0; | 896 | return 0; |
897 | mparam->param_name = tmpname; | 897 | mparam->param_name = tmpname; |
diff --git a/src/lib/libcrypto/asn1/f_enum.c b/src/lib/libcrypto/asn1/f_enum.c index e8736e5b72..98fa312266 100644 --- a/src/lib/libcrypto/asn1/f_enum.c +++ b/src/lib/libcrypto/asn1/f_enum.c | |||
@@ -154,12 +154,7 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) | |||
154 | } | 154 | } |
155 | i /= 2; | 155 | i /= 2; |
156 | if (num + i > slen) { | 156 | if (num + i > slen) { |
157 | if (s == NULL) | 157 | sp = realloc(s, (unsigned int)num + i * 2); |
158 | sp = (unsigned char *)malloc( | ||
159 | (unsigned int)num + i * 2); | ||
160 | else | ||
161 | sp = (unsigned char *)realloc(s, | ||
162 | (unsigned int)num + i * 2); | ||
163 | if (sp == NULL) { | 158 | if (sp == NULL) { |
164 | ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, | 159 | ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, |
165 | ERR_R_MALLOC_FAILURE); | 160 | ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c index f355dbacbe..3f671d1c49 100644 --- a/src/lib/libcrypto/asn1/f_int.c +++ b/src/lib/libcrypto/asn1/f_int.c | |||
@@ -158,12 +158,7 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) | |||
158 | } | 158 | } |
159 | i /= 2; | 159 | i /= 2; |
160 | if (num + i > slen) { | 160 | if (num + i > slen) { |
161 | if (s == NULL) | 161 | sp = OPENSSL_realloc_clean(s, slen, num + i * 2); |
162 | sp = (unsigned char *)malloc( | ||
163 | (unsigned int)num + i * 2); | ||
164 | else | ||
165 | sp = OPENSSL_realloc_clean(s, slen, | ||
166 | num + i * 2); | ||
167 | if (sp == NULL) { | 162 | if (sp == NULL) { |
168 | ASN1err(ASN1_F_A2I_ASN1_INTEGER, | 163 | ASN1err(ASN1_F_A2I_ASN1_INTEGER, |
169 | ERR_R_MALLOC_FAILURE); | 164 | ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c index d42bcdb6ea..c213c7a88d 100644 --- a/src/lib/libcrypto/asn1/f_string.c +++ b/src/lib/libcrypto/asn1/f_string.c | |||
@@ -150,12 +150,7 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) | |||
150 | } | 150 | } |
151 | i /= 2; | 151 | i /= 2; |
152 | if (num + i > slen) { | 152 | if (num + i > slen) { |
153 | if (s == NULL) | 153 | sp = realloc(s, (unsigned int)num + i * 2); |
154 | sp = (unsigned char *)malloc( | ||
155 | (unsigned int)num + i * 2); | ||
156 | else | ||
157 | sp = (unsigned char *)realloc(s, | ||
158 | (unsigned int)num + i * 2); | ||
159 | if (sp == NULL) { | 154 | if (sp == NULL) { |
160 | ASN1err(ASN1_F_A2I_ASN1_STRING, | 155 | ASN1err(ASN1_F_A2I_ASN1_STRING, |
161 | ERR_R_MALLOC_FAILURE); | 156 | ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c index 0e58baf1b5..1a724cfed7 100644 --- a/src/lib/libcrypto/asn1/n_pkey.c +++ b/src/lib/libcrypto/asn1/n_pkey.c | |||
@@ -163,7 +163,7 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, | |||
163 | } | 163 | } |
164 | 164 | ||
165 | /* Since its RC4 encrypted length is actual length */ | 165 | /* Since its RC4 encrypted length is actual length */ |
166 | if ((zz = (unsigned char *)malloc(rsalen)) == NULL) { | 166 | if ((zz = malloc(rsalen)) == NULL) { |
167 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); | 167 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); |
168 | goto err; | 168 | goto err; |
169 | } | 169 | } |
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c index de3fa22171..81333d67cf 100644 --- a/src/lib/libcrypto/asn1/t_x509.c +++ b/src/lib/libcrypto/asn1/t_x509.c | |||
@@ -265,7 +265,7 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
265 | if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) | 265 | if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) |
266 | goto err; | 266 | goto err; |
267 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); | 267 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); |
268 | if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL) | 268 | if ((der = dertmp = malloc(derlen)) == NULL) |
269 | goto err; | 269 | goto err; |
270 | i2d_X509_NAME(x->cert_info->subject, &dertmp); | 270 | i2d_X509_NAME(x->cert_info->subject, &dertmp); |
271 | 271 | ||
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c index dc9ddc413a..56c6a19cfb 100644 --- a/src/lib/libcrypto/asn1/tasn_new.c +++ b/src/lib/libcrypto/asn1/tasn_new.c | |||
@@ -156,10 +156,9 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | if (!combine) { | 158 | if (!combine) { |
159 | *pval = malloc(it->size); | 159 | *pval = calloc(1, it->size); |
160 | if (!*pval) | 160 | if (!*pval) |
161 | goto memerr; | 161 | goto memerr; |
162 | memset(*pval, 0, it->size); | ||
163 | } | 162 | } |
164 | asn1_set_choice_selector(pval, -1, it); | 163 | asn1_set_choice_selector(pval, -1, it); |
165 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) | 164 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) |
@@ -181,10 +180,9 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | |||
181 | } | 180 | } |
182 | } | 181 | } |
183 | if (!combine) { | 182 | if (!combine) { |
184 | *pval = malloc(it->size); | 183 | *pval = calloc(1, it->size); |
185 | if (!*pval) | 184 | if (!*pval) |
186 | goto memerr; | 185 | goto memerr; |
187 | memset(*pval, 0, it->size); | ||
188 | asn1_do_lock(pval, 0, it); | 186 | asn1_do_lock(pval, 0, it); |
189 | asn1_enc_init(pval, it); | 187 | asn1_enc_init(pval, it); |
190 | } | 188 | } |
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c index 4d3e2ebd17..2d1bf0d22d 100644 --- a/src/lib/libcrypto/asn1/x_info.c +++ b/src/lib/libcrypto/asn1/x_info.c | |||
@@ -67,7 +67,7 @@ X509_INFO_new(void) | |||
67 | { | 67 | { |
68 | X509_INFO *ret = NULL; | 68 | X509_INFO *ret = NULL; |
69 | 69 | ||
70 | ret = (X509_INFO *)malloc(sizeof(X509_INFO)); | 70 | ret = malloc(sizeof(X509_INFO)); |
71 | if (ret == NULL) { | 71 | if (ret == NULL) { |
72 | ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); | 72 | ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); |
73 | return (NULL); | 73 | return (NULL); |
diff --git a/src/lib/libssl/src/crypto/asn1/a_bitstr.c b/src/lib/libssl/src/crypto/asn1/a_bitstr.c index c578ce6279..f3cce8b536 100644 --- a/src/lib/libssl/src/crypto/asn1/a_bitstr.c +++ b/src/lib/libssl/src/crypto/asn1/a_bitstr.c | |||
@@ -153,7 +153,7 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) | |||
153 | 153 | ||
154 | if (len-- > 1) /* using one because of the bits left byte */ | 154 | if (len-- > 1) /* using one because of the bits left byte */ |
155 | { | 155 | { |
156 | s = (unsigned char *)malloc((int)len); | 156 | s = malloc((int)len); |
157 | if (s == NULL) { | 157 | if (s == NULL) { |
158 | i = ERR_R_MALLOC_FAILURE; | 158 | i = ERR_R_MALLOC_FAILURE; |
159 | goto err; | 159 | goto err; |
@@ -203,11 +203,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) | |||
203 | if ((a->length < (w + 1)) || (a->data == NULL)) { | 203 | if ((a->length < (w + 1)) || (a->data == NULL)) { |
204 | if (!value) | 204 | if (!value) |
205 | return(1); /* Don't need to set */ | 205 | return(1); /* Don't need to set */ |
206 | if (a->data == NULL) | 206 | c = OPENSSL_realloc_clean(a->data, a->length, w + 1); |
207 | c = (unsigned char *)malloc(w + 1); | ||
208 | else | ||
209 | c = (unsigned char *)OPENSSL_realloc_clean(a->data, | ||
210 | a->length, w + 1); | ||
211 | if (c == NULL) { | 207 | if (c == NULL) { |
212 | ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); | 208 | ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); |
213 | return 0; | 209 | return 0; |
diff --git a/src/lib/libssl/src/crypto/asn1/a_bytes.c b/src/lib/libssl/src/crypto/asn1/a_bytes.c index 30647c97b5..34ed7b7db2 100644 --- a/src/lib/libssl/src/crypto/asn1/a_bytes.c +++ b/src/lib/libssl/src/crypto/asn1/a_bytes.c | |||
@@ -99,7 +99,7 @@ d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
99 | ret = (*a); | 99 | ret = (*a); |
100 | 100 | ||
101 | if (len != 0) { | 101 | if (len != 0) { |
102 | s = (unsigned char *)malloc((int)len + 1); | 102 | s = malloc((int)len + 1); |
103 | if (s == NULL) { | 103 | if (s == NULL) { |
104 | i = ERR_R_MALLOC_FAILURE; | 104 | i = ERR_R_MALLOC_FAILURE; |
105 | goto err; | 105 | goto err; |
@@ -205,7 +205,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
205 | if ((ret->length < len) || (ret->data == NULL)) { | 205 | if ((ret->length < len) || (ret->data == NULL)) { |
206 | if (ret->data != NULL) | 206 | if (ret->data != NULL) |
207 | free(ret->data); | 207 | free(ret->data); |
208 | s = (unsigned char *)malloc((int)len + 1); | 208 | s = malloc(len + 1); |
209 | if (s == NULL) { | 209 | if (s == NULL) { |
210 | i = ERR_R_MALLOC_FAILURE; | 210 | i = ERR_R_MALLOC_FAILURE; |
211 | goto err; | 211 | goto err; |
diff --git a/src/lib/libssl/src/crypto/asn1/a_enum.c b/src/lib/libssl/src/crypto/asn1/a_enum.c index 5e6f7589cf..aa28c7c8d7 100644 --- a/src/lib/libssl/src/crypto/asn1/a_enum.c +++ b/src/lib/libssl/src/crypto/asn1/a_enum.c | |||
@@ -78,8 +78,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) | |||
78 | if (a->length < (int)(sizeof(long) + 1)) { | 78 | if (a->length < (int)(sizeof(long) + 1)) { |
79 | if (a->data != NULL) | 79 | if (a->data != NULL) |
80 | free(a->data); | 80 | free(a->data); |
81 | if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL) | 81 | a->data = calloc(1, sizeof(long) + 1); |
82 | memset((char *)a->data, 0, sizeof(long) + 1); | ||
83 | } | 82 | } |
84 | if (a->data == NULL) { | 83 | if (a->data == NULL) { |
85 | ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); | 84 | ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c b/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c index 082ba1b3a8..007e612b4a 100644 --- a/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c +++ b/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c | |||
@@ -89,7 +89,7 @@ ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) | |||
89 | int i, j = 0, n, ret = 1; | 89 | int i, j = 0, n, ret = 1; |
90 | 90 | ||
91 | n = i2d(x, NULL); | 91 | n = i2d(x, NULL); |
92 | b = (char *)malloc(n); | 92 | b = malloc(n); |
93 | if (b == NULL) { | 93 | if (b == NULL) { |
94 | ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); | 94 | ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); |
95 | return (0); | 95 | return (0); |
diff --git a/src/lib/libssl/src/crypto/asn1/a_int.c b/src/lib/libssl/src/crypto/asn1/a_int.c index 05776f572c..0559cce384 100644 --- a/src/lib/libssl/src/crypto/asn1/a_int.c +++ b/src/lib/libssl/src/crypto/asn1/a_int.c | |||
@@ -205,7 +205,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) | |||
205 | 205 | ||
206 | /* We must malloc stuff, even for 0 bytes otherwise it | 206 | /* We must malloc stuff, even for 0 bytes otherwise it |
207 | * signifies a missing NULL parameter. */ | 207 | * signifies a missing NULL parameter. */ |
208 | s = (unsigned char *)malloc((int)len + 1); | 208 | s = malloc((int)len + 1); |
209 | if (s == NULL) { | 209 | if (s == NULL) { |
210 | i = ERR_R_MALLOC_FAILURE; | 210 | i = ERR_R_MALLOC_FAILURE; |
211 | goto err; | 211 | goto err; |
@@ -309,7 +309,7 @@ d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length) | |||
309 | 309 | ||
310 | /* We must malloc stuff, even for 0 bytes otherwise it | 310 | /* We must malloc stuff, even for 0 bytes otherwise it |
311 | * signifies a missing NULL parameter. */ | 311 | * signifies a missing NULL parameter. */ |
312 | s = (unsigned char *)malloc((int)len + 1); | 312 | s = malloc((int)len + 1); |
313 | if (s == NULL) { | 313 | if (s == NULL) { |
314 | i = ERR_R_MALLOC_FAILURE; | 314 | i = ERR_R_MALLOC_FAILURE; |
315 | goto err; | 315 | goto err; |
@@ -352,8 +352,7 @@ ASN1_INTEGER_set(ASN1_INTEGER *a, long v) | |||
352 | if (a->length < (int)(sizeof(long) + 1)) { | 352 | if (a->length < (int)(sizeof(long) + 1)) { |
353 | if (a->data != NULL) | 353 | if (a->data != NULL) |
354 | free(a->data); | 354 | free(a->data); |
355 | if ((a->data = (unsigned char *)malloc(sizeof(long) + 1)) != NULL) | 355 | a->data = calloc(1, sizeof(long) + 1); |
356 | memset((char *)a->data, 0, sizeof(long) + 1); | ||
357 | } | 356 | } |
358 | if (a->data == NULL) { | 357 | if (a->data == NULL) { |
359 | ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); | 358 | ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/asn1/a_object.c b/src/lib/libssl/src/crypto/asn1/a_object.c index 93c755228a..f86d54f527 100644 --- a/src/lib/libssl/src/crypto/asn1/a_object.c +++ b/src/lib/libssl/src/crypto/asn1/a_object.c | |||
@@ -312,7 +312,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) | |||
312 | ret->length = 0; | 312 | ret->length = 0; |
313 | if (data != NULL) | 313 | if (data != NULL) |
314 | free(data); | 314 | free(data); |
315 | data = (unsigned char *)malloc(len ? (int)len : 1); | 315 | data = malloc(len ? (int)len : 1); |
316 | if (data == NULL) { | 316 | if (data == NULL) { |
317 | i = ERR_R_MALLOC_FAILURE; | 317 | i = ERR_R_MALLOC_FAILURE; |
318 | goto err; | 318 | goto err; |
@@ -345,7 +345,7 @@ ASN1_OBJECT_new(void) | |||
345 | { | 345 | { |
346 | ASN1_OBJECT *ret; | 346 | ASN1_OBJECT *ret; |
347 | 347 | ||
348 | ret = (ASN1_OBJECT *)malloc(sizeof(ASN1_OBJECT)); | 348 | ret = malloc(sizeof(ASN1_OBJECT)); |
349 | if (ret == NULL) { | 349 | if (ret == NULL) { |
350 | ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); | 350 | ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); |
351 | return (NULL); | 351 | return (NULL); |
diff --git a/src/lib/libssl/src/crypto/asn1/ameth_lib.c b/src/lib/libssl/src/crypto/asn1/ameth_lib.c index 63ff18edae..8652e938bd 100644 --- a/src/lib/libssl/src/crypto/asn1/ameth_lib.c +++ b/src/lib/libssl/src/crypto/asn1/ameth_lib.c | |||
@@ -287,12 +287,10 @@ EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) | |||
287 | { | 287 | { |
288 | EVP_PKEY_ASN1_METHOD *ameth; | 288 | EVP_PKEY_ASN1_METHOD *ameth; |
289 | 289 | ||
290 | ameth = malloc(sizeof(EVP_PKEY_ASN1_METHOD)); | 290 | ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD)); |
291 | if (!ameth) | 291 | if (!ameth) |
292 | return NULL; | 292 | return NULL; |
293 | 293 | ||
294 | memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD)); | ||
295 | |||
296 | ameth->pkey_id = id; | 294 | ameth->pkey_id = id; |
297 | ameth->pkey_base_id = id; | 295 | ameth->pkey_base_id = id; |
298 | ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; | 296 | ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; |
diff --git a/src/lib/libssl/src/crypto/asn1/asn1_lib.c b/src/lib/libssl/src/crypto/asn1/asn1_lib.c index f3b2f0480f..4d4368aefe 100644 --- a/src/lib/libssl/src/crypto/asn1/asn1_lib.c +++ b/src/lib/libssl/src/crypto/asn1/asn1_lib.c | |||
@@ -418,7 +418,7 @@ ASN1_STRING_type_new(int type) | |||
418 | { | 418 | { |
419 | ASN1_STRING *ret; | 419 | ASN1_STRING *ret; |
420 | 420 | ||
421 | ret = (ASN1_STRING *)malloc(sizeof(ASN1_STRING)); | 421 | ret = malloc(sizeof(ASN1_STRING)); |
422 | if (ret == NULL) { | 422 | if (ret == NULL) { |
423 | ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); | 423 | ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); |
424 | return (NULL); | 424 | return (NULL); |
diff --git a/src/lib/libssl/src/crypto/asn1/asn_mime.c b/src/lib/libssl/src/crypto/asn1/asn_mime.c index 890557578d..248ea114e8 100644 --- a/src/lib/libssl/src/crypto/asn1/asn_mime.c +++ b/src/lib/libssl/src/crypto/asn1/asn_mime.c | |||
@@ -850,7 +850,7 @@ mime_hdr_new(char *name, char *value) | |||
850 | } | 850 | } |
851 | } | 851 | } |
852 | } else tmpval = NULL; | 852 | } else tmpval = NULL; |
853 | mhdr = (MIME_HEADER *)malloc(sizeof(MIME_HEADER)); | 853 | mhdr = malloc(sizeof(MIME_HEADER)); |
854 | if (!mhdr) { | 854 | if (!mhdr) { |
855 | OPENSSL_free(tmpname); | 855 | OPENSSL_free(tmpname); |
856 | return NULL; | 856 | return NULL; |
@@ -891,7 +891,7 @@ mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) | |||
891 | } else | 891 | } else |
892 | tmpval = NULL; | 892 | tmpval = NULL; |
893 | /* Parameter values are case sensitive so leave as is */ | 893 | /* Parameter values are case sensitive so leave as is */ |
894 | mparam = (MIME_PARAM *) malloc(sizeof(MIME_PARAM)); | 894 | mparam = malloc(sizeof(MIME_PARAM)); |
895 | if (!mparam) | 895 | if (!mparam) |
896 | return 0; | 896 | return 0; |
897 | mparam->param_name = tmpname; | 897 | mparam->param_name = tmpname; |
diff --git a/src/lib/libssl/src/crypto/asn1/f_enum.c b/src/lib/libssl/src/crypto/asn1/f_enum.c index e8736e5b72..98fa312266 100644 --- a/src/lib/libssl/src/crypto/asn1/f_enum.c +++ b/src/lib/libssl/src/crypto/asn1/f_enum.c | |||
@@ -154,12 +154,7 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) | |||
154 | } | 154 | } |
155 | i /= 2; | 155 | i /= 2; |
156 | if (num + i > slen) { | 156 | if (num + i > slen) { |
157 | if (s == NULL) | 157 | sp = realloc(s, (unsigned int)num + i * 2); |
158 | sp = (unsigned char *)malloc( | ||
159 | (unsigned int)num + i * 2); | ||
160 | else | ||
161 | sp = (unsigned char *)realloc(s, | ||
162 | (unsigned int)num + i * 2); | ||
163 | if (sp == NULL) { | 158 | if (sp == NULL) { |
164 | ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, | 159 | ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, |
165 | ERR_R_MALLOC_FAILURE); | 160 | ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/asn1/f_int.c b/src/lib/libssl/src/crypto/asn1/f_int.c index f355dbacbe..3f671d1c49 100644 --- a/src/lib/libssl/src/crypto/asn1/f_int.c +++ b/src/lib/libssl/src/crypto/asn1/f_int.c | |||
@@ -158,12 +158,7 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) | |||
158 | } | 158 | } |
159 | i /= 2; | 159 | i /= 2; |
160 | if (num + i > slen) { | 160 | if (num + i > slen) { |
161 | if (s == NULL) | 161 | sp = OPENSSL_realloc_clean(s, slen, num + i * 2); |
162 | sp = (unsigned char *)malloc( | ||
163 | (unsigned int)num + i * 2); | ||
164 | else | ||
165 | sp = OPENSSL_realloc_clean(s, slen, | ||
166 | num + i * 2); | ||
167 | if (sp == NULL) { | 162 | if (sp == NULL) { |
168 | ASN1err(ASN1_F_A2I_ASN1_INTEGER, | 163 | ASN1err(ASN1_F_A2I_ASN1_INTEGER, |
169 | ERR_R_MALLOC_FAILURE); | 164 | ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/asn1/f_string.c b/src/lib/libssl/src/crypto/asn1/f_string.c index d42bcdb6ea..c213c7a88d 100644 --- a/src/lib/libssl/src/crypto/asn1/f_string.c +++ b/src/lib/libssl/src/crypto/asn1/f_string.c | |||
@@ -150,12 +150,7 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) | |||
150 | } | 150 | } |
151 | i /= 2; | 151 | i /= 2; |
152 | if (num + i > slen) { | 152 | if (num + i > slen) { |
153 | if (s == NULL) | 153 | sp = realloc(s, (unsigned int)num + i * 2); |
154 | sp = (unsigned char *)malloc( | ||
155 | (unsigned int)num + i * 2); | ||
156 | else | ||
157 | sp = (unsigned char *)realloc(s, | ||
158 | (unsigned int)num + i * 2); | ||
159 | if (sp == NULL) { | 154 | if (sp == NULL) { |
160 | ASN1err(ASN1_F_A2I_ASN1_STRING, | 155 | ASN1err(ASN1_F_A2I_ASN1_STRING, |
161 | ERR_R_MALLOC_FAILURE); | 156 | ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/asn1/n_pkey.c b/src/lib/libssl/src/crypto/asn1/n_pkey.c index 0e58baf1b5..1a724cfed7 100644 --- a/src/lib/libssl/src/crypto/asn1/n_pkey.c +++ b/src/lib/libssl/src/crypto/asn1/n_pkey.c | |||
@@ -163,7 +163,7 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, | |||
163 | } | 163 | } |
164 | 164 | ||
165 | /* Since its RC4 encrypted length is actual length */ | 165 | /* Since its RC4 encrypted length is actual length */ |
166 | if ((zz = (unsigned char *)malloc(rsalen)) == NULL) { | 166 | if ((zz = malloc(rsalen)) == NULL) { |
167 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); | 167 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); |
168 | goto err; | 168 | goto err; |
169 | } | 169 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_x509.c b/src/lib/libssl/src/crypto/asn1/t_x509.c index de3fa22171..81333d67cf 100644 --- a/src/lib/libssl/src/crypto/asn1/t_x509.c +++ b/src/lib/libssl/src/crypto/asn1/t_x509.c | |||
@@ -265,7 +265,7 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
265 | if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) | 265 | if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) |
266 | goto err; | 266 | goto err; |
267 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); | 267 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); |
268 | if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL) | 268 | if ((der = dertmp = malloc(derlen)) == NULL) |
269 | goto err; | 269 | goto err; |
270 | i2d_X509_NAME(x->cert_info->subject, &dertmp); | 270 | i2d_X509_NAME(x->cert_info->subject, &dertmp); |
271 | 271 | ||
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_new.c b/src/lib/libssl/src/crypto/asn1/tasn_new.c index dc9ddc413a..56c6a19cfb 100644 --- a/src/lib/libssl/src/crypto/asn1/tasn_new.c +++ b/src/lib/libssl/src/crypto/asn1/tasn_new.c | |||
@@ -156,10 +156,9 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | if (!combine) { | 158 | if (!combine) { |
159 | *pval = malloc(it->size); | 159 | *pval = calloc(1, it->size); |
160 | if (!*pval) | 160 | if (!*pval) |
161 | goto memerr; | 161 | goto memerr; |
162 | memset(*pval, 0, it->size); | ||
163 | } | 162 | } |
164 | asn1_set_choice_selector(pval, -1, it); | 163 | asn1_set_choice_selector(pval, -1, it); |
165 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) | 164 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) |
@@ -181,10 +180,9 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | |||
181 | } | 180 | } |
182 | } | 181 | } |
183 | if (!combine) { | 182 | if (!combine) { |
184 | *pval = malloc(it->size); | 183 | *pval = calloc(1, it->size); |
185 | if (!*pval) | 184 | if (!*pval) |
186 | goto memerr; | 185 | goto memerr; |
187 | memset(*pval, 0, it->size); | ||
188 | asn1_do_lock(pval, 0, it); | 186 | asn1_do_lock(pval, 0, it); |
189 | asn1_enc_init(pval, it); | 187 | asn1_enc_init(pval, it); |
190 | } | 188 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/x_info.c b/src/lib/libssl/src/crypto/asn1/x_info.c index 4d3e2ebd17..2d1bf0d22d 100644 --- a/src/lib/libssl/src/crypto/asn1/x_info.c +++ b/src/lib/libssl/src/crypto/asn1/x_info.c | |||
@@ -67,7 +67,7 @@ X509_INFO_new(void) | |||
67 | { | 67 | { |
68 | X509_INFO *ret = NULL; | 68 | X509_INFO *ret = NULL; |
69 | 69 | ||
70 | ret = (X509_INFO *)malloc(sizeof(X509_INFO)); | 70 | ret = malloc(sizeof(X509_INFO)); |
71 | if (ret == NULL) { | 71 | if (ret == NULL) { |
72 | ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); | 72 | ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); |
73 | return (NULL); | 73 | return (NULL); |