memlimit.c: ignore sysconf() failures
When using qemu-arm, sysconf(_SC_PAGE_SIZE) returns an error
with an errno of ENOSYS. This change ignores ENOSYS since
the result would be the same as when _SC_PAGE_SIZE was not
defined. This makes scrypt work in cryptohome unittests.
The "right" solution is to add a new macro via configure that
wraps up the _SC_PAGE_SIZE test along with a compile-time test
for sysconf() to work. It seems like overkill, but probably
the right move for upstreaming.
TEST=builds and cryptohome tests work under qemu-arm
BUG=chromium-os:38444
Signed-off-by: Will Drewry <wad@chromium.org>
Change-Id: Ic04d19b0d1553c4e57f562cdcee99e59b300f2e0
Reviewed-on: https://gerrit.chromium.org/gerrit/42579
Reviewed-by: Kees Cook <keescook@chromium.org>
Commit-Queue: Will Drewry <wad@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
diff --git a/src/lib/util/memlimit.c b/src/lib/util/memlimit.c
index 8303f5c..b5b5c45 100644
--- a/src/lib/util/memlimit.c
+++ b/src/lib/util/memlimit.c
@@ -207,7 +207,8 @@
if (((pagesize = sysconf(_SC_PAGE_SIZE)) == -1) ||
((physpages = sysconf(_SC_PHYS_PAGES)) == -1)) {
/* Did an error occur? */
- if (errno != 0)
+ /* TODO: wrap ENOSYS with autoconf detection testing. */
+ if (errno != 0 && errno != ENOSYS)
return (1);
/* If not, there is no limit. */