[Cryptech-Commits] [sw/libhal] 04/11: Use sysconf(_SC_PAGESIZE) instead of getpagesize().
git at cryptech.is
git at cryptech.is
Wed Dec 23 07:22:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch rpc
in repository sw/libhal.
commit 808c0bac0d91480d57ccf9add3adc35061838c10
Author: Rob Austein <sra at hactrn.net>
Date: Sun Dec 20 20:06:06 2015 -0500
Use sysconf(_SC_PAGESIZE) instead of getpagesize().
---
ks_mmap.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/ks_mmap.c b/ks_mmap.c
index 3ff06a3..7fef400 100644
--- a/ks_mmap.c
+++ b/ks_mmap.c
@@ -38,6 +38,7 @@
#include <sys/mman.h>
#include <string.h>
#include <sys/errno.h>
+#include <unistd.h>
#include "hal.h"
#include "hal_internal.h"
@@ -46,6 +47,10 @@
#define HAL_KS_MMAP_FILE ".cryptech_hal_keystore"
#endif
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+
static hal_ks_keydb_t *db;
const hal_ks_keydb_t *hal_ks_get_keydb(void)
@@ -56,13 +61,16 @@ const hal_ks_keydb_t *hal_ks_get_keydb(void)
const char * const env = getenv("CRYPTECH_KEYSTORE");
const char * const home = getenv("HOME");
const char * const base = HAL_KS_MMAP_FILE;
- const unsigned pagemask = getpagesize() - 1;
+ const long pagemask = sysconf(_SC_PAGESIZE) - 1;
const size_t len = (sizeof(hal_ks_keydb_t) + pagemask) & ~pagemask;
char fn_[strlen(base) + (home == NULL ? 0 : strlen(home)) + 2];
const char *fn = fn_;
int fd;
+ if (pagemask < 0)
+ return NULL;
+
if (env != NULL)
fn = env;
else if (home == NULL)
More information about the Commits
mailing list