Browse Source

Mem-sec small code adjustment

Conditional code readability improvement.

Remove unused macro

Commit #11042 has introduced a new, unused, CRYPTO_EX_INDEX macro.
Remove before version release.

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11103)
master
Davide Galassi 2 years ago
committed by Pauli
parent
commit
d27fd99110
2 changed files with 9 additions and 12 deletions
  1. +8
    -10
      crypto/mem_sec.c
  2. +1
    -2
      include/openssl/crypto.h

+ 8
- 10
crypto/mem_sec.c 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
@ -385,12 +382,12 @@ static int sh_init(size_t size, size_t minsize)
OPENSSL_assert(size > 0);
OPENSSL_assert((size & (size - 1)) == 0);
OPENSSL_assert((minsize & (minsize - 1)) == 0);
if (size <= 0 || (size & (size - 1)) != 0)
if (size == 0 || (size & (size - 1)) != 0)
goto err;
if (minsize == 0 || (minsize & (minsize - 1)) != 0)
goto err;
while (minsize < (int)sizeof(SH_LIST))
while (minsize < sizeof(SH_LIST))
minsize *= 2;
sh.arena_size = size;
@ -437,12 +434,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 +449,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);


+ 1
- 2
include/openssl/crypto.h View File

@ -192,8 +192,7 @@ DEFINE_STACK_OF(void)
# define CRYPTO_EX_INDEX_RAND_DRBG 15
# define CRYPTO_EX_INDEX_DRBG CRYPTO_EX_INDEX_RAND_DRBG
# define CRYPTO_EX_INDEX_OPENSSL_CTX 16
# define CRYPTO_EX_INDEX_COUNT 17
# define CRYPTO_EX_INDEX__COUNT CRYPTO_EX_INDEX_COUNT
# define CRYPTO_EX_INDEX__COUNT 17
typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
int idx, long argl, void *argp);


Loading…
Cancel
Save