diff options
author | Pauli <paul.dale@oracle.com> | 2020-02-05 09:09:29 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-02-05 09:09:29 +1000 |
commit | 34b167625af50a13b8414e11814a795457cb17b0 (patch) | |
tree | 267626b384a898eda7e749bb992fefca36a2e64b /crypto | |
parent | e3b1ccad694aabfffbde68c56fb8d44c011f98b1 (diff) |
Make minimum size for secure memory a size_t.
The minimum size argument to CRYPTO_secure_malloc_init() was an int but ought
to be a size_t since it is a size.
From an API perspective, this is a change. However, the minimum size is
verified as being a positive power of two and it will typically be a small
constant.
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from #11003)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/mem_sec.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c index 65d32f3c41..6aca27370e 100644 --- a/crypto/mem_sec.c +++ b/crypto/mem_sec.c @@ -57,7 +57,7 @@ static CRYPTO_RWLOCK *sec_malloc_lock = NULL; /* * These are the functions that must be implemented by a secure heap (sh). */ -static int sh_init(size_t size, int minsize); +static int sh_init(size_t size, size_t minsize); static void *sh_malloc(size_t size); static void sh_free(void *ptr); static void sh_done(void); @@ -65,7 +65,7 @@ static size_t sh_actual_size(char *ptr); static int sh_allocated(const char *ptr); #endif -int CRYPTO_secure_malloc_init(size_t size, int minsize) +int CRYPTO_secure_malloc_init(size_t size, size_t minsize) { #ifdef OPENSSL_SECURE_MEMORY int ret = 0; @@ -373,7 +373,7 @@ static void sh_remove_from_list(char *ptr) } -static int sh_init(size_t size, int minsize) +static int sh_init(size_t size, size_t minsize) { int ret; size_t i; @@ -385,11 +385,10 @@ static int sh_init(size_t size, int minsize) /* make sure size and minsize are powers of 2 */ OPENSSL_assert(size > 0); OPENSSL_assert((size & (size - 1)) == 0); - OPENSSL_assert(minsize > 0); OPENSSL_assert((minsize & (minsize - 1)) == 0); if (size <= 0 || (size & (size - 1)) != 0) goto err; - if (minsize <= 0 || (minsize & (minsize - 1)) != 0) + if (minsize == 0 || (minsize & (minsize - 1)) != 0) goto err; while (minsize < (int)sizeof(SH_LIST)) |