diff options
author | Matt Caswell <matt@openssl.org> | 2015-11-12 15:11:34 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-11-17 11:23:51 +0000 |
commit | 9ae720b4dc30ab52b20965c5d6f60ecc6169b8c8 (patch) | |
tree | 6ca543d5729bfb519ff71f1f58c7418890252601 | |
parent | ae4d0c8d227d0cf4f9f3f7a5d07189c0a18b25fc (diff) | |
download | openssl-9ae720b4dc30ab52b20965c5d6f60ecc6169b8c8.zip openssl-9ae720b4dc30ab52b20965c5d6f60ecc6169b8c8.tar.gz openssl-9ae720b4dc30ab52b20965c5d6f60ecc6169b8c8.tar.bz2 |
Check error return from sysconf in secure memory code
We use the sysconf function to provide details about the page size in the
secure memory code. This function can return -1 on error so we should check
for this before proceeding.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
-rw-r--r-- | crypto/sec_mem.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crypto/sec_mem.c b/crypto/sec_mem.c index 2e29219..0b2f1fd 100644 --- a/crypto/sec_mem.c +++ b/crypto/sec_mem.c @@ -333,8 +333,18 @@ static int sh_init(size_t size, int minsize) goto err; /* Allocate space for heap, and two extra pages as guards */ -#ifdef _SC_PAGE_SIZE - pgsize = (size_t)sysconf(_SC_PAGE_SIZE); +#if defined(_SC_PAGE_SIZE) || defined (_SC_PAGESIZE) + { +# if defined(_SC_PAGE_SIZE) + long tmppgsize = sysconf(_SC_PAGE_SIZE); +# else + long tmppgsize = sysconf(_SC_PAGESIZE); +# endif + if (tmppgsize < 1) + pgsize = PAGE_SIZE; + else + pgsize = (size_t)tmppgsize; + } #else pgsize = PAGE_SIZE; #endif |