summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2018-05-13 13:48:08 +0000
committerjsing <>2018-05-13 13:48:08 +0000
commit294ab72401fb4b21de1eb8cfc698fba7c7f676f9 (patch)
tree96ffa806e6015ca7656a37095f52d0238b382a31
parent5c4fd695e4ce135d2abc9d0272d5dcc6c5ca68be (diff)
downloadopenbsd-294ab72401fb4b21de1eb8cfc698fba7c7f676f9.tar.gz
openbsd-294ab72401fb4b21de1eb8cfc698fba7c7f676f9.tar.bz2
openbsd-294ab72401fb4b21de1eb8cfc698fba7c7f676f9.zip
Use recallocarray() instead of OPENSSL_realloc_clean().
Also place all of the OPENSSL_* memory related prototypes under #ifndef LIBRESSL_INTERNAL. ok beck@ tb@
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c7
-rw-r--r--src/lib/libcrypto/asn1/f_int.c5
-rw-r--r--src/lib/libcrypto/crypto.h4
3 files changed, 7 insertions, 9 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 7fa5af9bbb..11771bdd02 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_bitstr.c,v 1.27 2018/05/12 17:44:31 jsing Exp $ */ 1/* $OpenBSD: a_bitstr.c,v 1.28 2018/05/13 13:48:08 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -190,8 +190,6 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len)
190 return (NULL); 190 return (NULL);
191} 191}
192 192
193/* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
194 */
195int 193int
196ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) 194ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
197{ 195{
@@ -212,8 +210,7 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
212 if ((a->length < (w + 1)) || (a->data == NULL)) { 210 if ((a->length < (w + 1)) || (a->data == NULL)) {
213 if (!value) 211 if (!value)
214 return(1); /* Don't need to set */ 212 return(1); /* Don't need to set */
215 c = OPENSSL_realloc_clean(a->data, a->length, w + 1); 213 if ((c = recallocarray(a->data, a->length, w + 1, 1)) == NULL) {
216 if (c == NULL) {
217 ASN1error(ERR_R_MALLOC_FAILURE); 214 ASN1error(ERR_R_MALLOC_FAILURE);
218 return 0; 215 return 0;
219 } 216 }
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 9849a7c8fc..d03fafe87d 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: f_int.c,v 1.19 2018/04/25 11:48:21 tb Exp $ */ 1/* $OpenBSD: f_int.c,v 1.20 2018/05/13 13:48:08 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -158,8 +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 sp = OPENSSL_realloc_clean(s, slen, num + i); 161 if ((sp = recallocarray(s, slen, num + i, 1)) == NULL) {
162 if (sp == NULL) {
163 ASN1error(ERR_R_MALLOC_FAILURE); 162 ASN1error(ERR_R_MALLOC_FAILURE);
164 goto err; 163 goto err;
165 } 164 }
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 67e06a1509..be5f92b1a3 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto.h,v 1.45 2018/03/19 03:35:38 beck Exp $ */ 1/* $OpenBSD: crypto.h,v 1.46 2018/05/13 13:48:08 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -299,6 +299,7 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
299 * via CRYPTO_ex_data_new_class). */ 299 * via CRYPTO_ex_data_new_class). */
300#define CRYPTO_EX_INDEX_USER 100 300#define CRYPTO_EX_INDEX_USER 100
301 301
302#ifndef LIBRESSL_INTERNAL
302#define CRYPTO_malloc_init() (0) 303#define CRYPTO_malloc_init() (0)
303#define CRYPTO_malloc_debug_init() (0) 304#define CRYPTO_malloc_debug_init() (0)
304 305
@@ -329,6 +330,7 @@ int CRYPTO_is_mem_check_on(void);
329#define OPENSSL_malloc_locked(num) \ 330#define OPENSSL_malloc_locked(num) \
330 CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) 331 CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
331#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) 332#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
333#endif
332 334
333const char *OpenSSL_version(int type); 335const char *OpenSSL_version(int type);
334#define OPENSSL_VERSION 0 336#define OPENSSL_VERSION 0