diff options
author | Rob Austein <sra@hactrn.net> | 2015-12-20 20:06:06 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-12-20 20:06:06 -0500 |
commit | 808c0bac0d91480d57ccf9add3adc35061838c10 (patch) | |
tree | eb056636840a0fb01a78682f5c2cd1308c723003 /ks_mmap.c | |
parent | 0336850c447ee44c21383ffb7df416ce1623378b (diff) |
Use sysconf(_SC_PAGESIZE) instead of getpagesize().
Diffstat (limited to 'ks_mmap.c')
-rw-r--r-- | ks_mmap.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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) |