[git] GCRYPT - branch, master, updated. libgcrypt-1.8.1-21-g621f5c4
by NIIBE Yutaka
cvs at cvs.gnupg.org
Thu Nov 9 03:02:00 CET 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".
The branch, master has been updated
via 621f5c4e837347308a6b06a8cfbfc47ca9fae69e (commit)
from 77e314a42a9c3c3557f0e60b3bf6da2ff9f7709a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 621f5c4e837347308a6b06a8cfbfc47ca9fae69e
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Thu Nov 9 10:59:33 2017 +0900
Fix secmem test for machine with larger page.
* tests/t-secmem.c (main): Detect page size and setup chunk size.
* src/secmem.c (init_pool): Simplify the expression.
--
GnuPG-bug-id: 3351
Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
diff --git a/src/secmem.c b/src/secmem.c
index 86de72d..f7ad1f6 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -407,7 +407,7 @@ init_pool (pooldesc_t *pool, size_t n)
# else
pgsize_val = -1;
# endif
- pgsize = (pgsize_val != -1 && pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
+ pgsize = (pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
pool->size = (pool->size + pgsize - 1) & ~(pgsize - 1);
# ifdef MAP_ANONYMOUS
diff --git a/tests/t-secmem.c b/tests/t-secmem.c
index 8f4cce1..ecbc55a 100644
--- a/tests/t-secmem.c
+++ b/tests/t-secmem.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#define PGM "t-secmem"
@@ -32,6 +33,11 @@
#include "../src/gcrypt-testapi.h"
+#define DEFAULT_PAGE_SIZE 4096
+#define MINIMUM_POOL_SIZE 16384
+static size_t pool_size;
+static size_t chunk_size;
+
static void
test_secmem (void)
{
@@ -42,12 +48,12 @@ test_secmem (void)
memset (a, 0, sizeof a);
/* Allocating 28*512=14k should work in the default 16k pool even
- * with extrem alignment requirements. */
+ * with extra alignment requirements. */
for (i=0; i < DIM(a); i++)
- a[i] = gcry_xmalloc_secure (512);
+ a[i] = gcry_xmalloc_secure (chunk_size);
/* Allocating another 2k should fail for the default 16k pool. */
- b = gcry_malloc_secure (2048);
+ b = gcry_malloc_secure (chunk_size*4);
if (b)
fail ("allocation did not fail as expected\n");
@@ -68,7 +74,7 @@ test_secmem_overflow (void)
/* Allocating 150*512=75k should require more than one overflow buffer. */
for (i=0; i < DIM(a); i++)
{
- a[i] = gcry_xmalloc_secure (512);
+ a[i] = gcry_xmalloc_secure (chunk_size);
if (verbose && !(i %40))
xgcry_control (GCRYCTL_DUMP_SECMEM_STATS, 0 , 0);
}
@@ -111,6 +117,18 @@ int
main (int argc, char **argv)
{
int last_argc = -1;
+ long int pgsize_val = -1;
+ size_t pgsize;
+
+# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+ pgsize_val = sysconf (_SC_PAGESIZE);
+# elif defined(HAVE_GETPAGESIZE)
+ pgsize_val = getpagesize ();
+# endif
+ pgsize = (pgsize_val > 0)? pgsize_val : DEFAULT_PAGE_SIZE;
+
+ pool_size = (MINIMUM_POOL_SIZE + pgsize - 1) & ~(pgsize - 1);
+ chunk_size = pool_size / 32;
if (argc)
{ argc--; argv++; }
@@ -153,7 +171,7 @@ main (int argc, char **argv)
if (debug)
xgcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
xgcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
- xgcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+ xgcry_control (GCRYCTL_INIT_SECMEM, pool_size, 0);
gcry_set_outofcore_handler (outofcore_handler, NULL);
xgcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
-----------------------------------------------------------------------
Summary of changes:
src/secmem.c | 2 +-
tests/t-secmem.c | 28 +++++++++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
hooks/post-receive
--
The GNU crypto library
http://git.gnupg.org
_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits
More information about the Gcrypt-devel
mailing list