aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2007-04-16 13:37:09 +0000
committerDavid Shaw <[email protected]>2007-04-16 13:37:09 +0000
commit3a2e31ff19acd8d5aaad856ea8a7c774b092ff10 (patch)
tree1ea4c6e7f267c713e81a38c178ab148ea9bc9be3
parent* argparse.c (default_strusage): Copyright 2007. (diff)
downloadgnupg-3a2e31ff19acd8d5aaad856ea8a7c774b092ff10.tar.gz
gnupg-3a2e31ff19acd8d5aaad856ea8a7c774b092ff10.zip
Use sysconf() when possible as not all platforms have getpagesize().
-rw-r--r--ChangeLog7
-rw-r--r--acinclude.m411
-rw-r--r--configure.ac2
-rw-r--r--util/ChangeLog5
-rw-r--r--util/secmem.c14
5 files changed, 32 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b96760bff..a7cc52620 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-04-16 David Shaw <[email protected]>
+
+ * acinclude.m4: Use sysconf() if available to avoid a false
+ positive on HAVE_BROKEN_MLOCK when checking for page size.
+
+ * configure.ac: Check for sysconf.
+
2007-04-15 David Shaw <[email protected]>
* configure.ac: QNX puts resolver functions in libsocket. From
diff --git a/acinclude.m4 b/acinclude.m4
index fb7edde38..30eeb85d6 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -420,7 +420,16 @@ define(GNUPG_CHECK_MLOCK,
{
char *pool;
int err;
- long int pgsize = getpagesize();
+ long int pgsize;
+
+ #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+ pgsize = sysconf(_SC_PAGESIZE);
+ #elif defined(HAVE_GETPAGESIZE)
+ pgsize = getpagesize();
+ #endif
+
+ if(pgsize==-1)
+ pgsize = 4096;
pool = malloc( 4096 + pgsize );
if( !pool )
diff --git a/configure.ac b/configure.ac
index 6a30e8ef8..10ffb7c16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -953,7 +953,7 @@ AC_CHECK_DECLS(getpagesize)
AC_FUNC_FSEEKO
AC_FUNC_VPRINTF
AC_FUNC_FORK
-AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap)
+AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap sysconf)
AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid times unsetenv getpwnam getpwuid)
AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale)
diff --git a/util/ChangeLog b/util/ChangeLog
index 226f24592..70a95c758 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+2007-04-16 David Shaw <[email protected]>
+
+ * secmem.c (init_pool): Use sysconf() if available to determine
+ page size.
+
2007-04-15 David Shaw <[email protected]>
* argparse.c (default_strusage): Copyright 2007.
diff --git a/util/secmem.c b/util/secmem.c
index a0248dae1..dc8a8f087 100644
--- a/util/secmem.c
+++ b/util/secmem.c
@@ -1,5 +1,6 @@
/* secmem.c - memory allocation from a secure heap
- * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ * 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -218,19 +219,22 @@ lock_pool( void *p, size_t n )
static void
init_pool( size_t n)
{
- size_t pgsize;
+ size_t pgsize=-1;
poolsize = n;
if( disable_secmem )
log_bug("secure memory is disabled");
-#ifdef HAVE_GETPAGESIZE
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+ pgsize = sysconf(_SC_PAGESIZE);
+#elif defined(HAVE_GETPAGESIZE)
pgsize = getpagesize();
-#else
- pgsize = 4096;
#endif
+ if(pgsize==-1)
+ pgsize = 4096;
+
#ifdef HAVE_MMAP
poolsize = (poolsize + pgsize -1 ) & ~(pgsize-1);
#ifdef MAP_ANONYMOUS