Latest update.

This commit is contained in:
2020-03-03 19:16:19 +09:00
parent f85de4da03
commit b412d79e8b
310 changed files with 32765 additions and 19720 deletions
+29 -15
View File
@@ -227,9 +227,6 @@ size_t CRYPTO_secure_actual_size(void *ptr)
return 0;
#endif
}
/* END OF PAGE ...
... START OF PAGE */
/*
* SECURE HEAP IMPLEMENTATION
@@ -381,17 +378,33 @@ static int sh_init(size_t size, size_t minsize)
memset(&sh, 0, sizeof(sh));
/* make sure size and minsize are powers of 2 */
/* make sure size is a powers of 2 */
OPENSSL_assert(size > 0);
OPENSSL_assert((size & (size - 1)) == 0);
OPENSSL_assert((minsize & (minsize - 1)) == 0);
if (size <= 0 || (size & (size - 1)) != 0)
goto err;
if (minsize == 0 || (minsize & (minsize - 1)) != 0)
if (size == 0 || (size & (size - 1)) != 0)
goto err;
while (minsize < (int)sizeof(SH_LIST))
minsize *= 2;
if (minsize <= sizeof(SH_LIST)) {
OPENSSL_assert(sizeof(SH_LIST) <= 65536);
/*
* Compute the minimum possible allocation size.
* This must be a power of 2 and at least as large as the SH_LIST
* structure.
*/
minsize = sizeof(SH_LIST) - 1;
minsize |= minsize >> 1;
minsize |= minsize >> 2;
if (sizeof(SH_LIST) > 16)
minsize |= minsize >> 4;
if (sizeof(SH_LIST) > 256)
minsize |= minsize >> 8;
minsize++;
} else {
/* make sure minsize is a powers of 2 */
OPENSSL_assert((minsize & (minsize - 1)) == 0);
if ((minsize & (minsize - 1)) != 0)
goto err;
}
sh.arena_size = size;
sh.minsize = minsize;
@@ -437,12 +450,12 @@ static int sh_init(size_t size, size_t minsize)
pgsize = PAGE_SIZE;
#endif
sh.map_size = pgsize + sh.arena_size + pgsize;
if (1) {
#ifdef MAP_ANON
sh.map_result = mmap(NULL, sh.map_size,
PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
} else {
#endif
sh.map_result = mmap(NULL, sh.map_size,
PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
#else
{
int fd;
sh.map_result = MAP_FAILED;
@@ -452,6 +465,7 @@ static int sh_init(size_t size, size_t minsize)
close(fd);
}
}
#endif
if (sh.map_result == MAP_FAILED)
goto err;
sh.arena = (char *)(sh.map_result + pgsize);