commit 41769b976a17a5704cfc0ae27d1ec72c54fbf52e parent 9c37575961239dc7d0d203fff341c0c7677950ba Author: sin <sin@2f30.org> Date: Tue, 29 Oct 2013 15:54:12 +0000 Check for a valid pagesize in mkswap(8) Diffstat:
M | mkswap.c | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/mkswap.c b/mkswap.c @@ -45,7 +45,12 @@ main(int argc, char *argv[]) if (argc < 1) usage(); - pagesize = sysconf(_SC_PAGE_SIZE); + pagesize = sysconf(_SC_PAGESIZE); + if (pagesize <= 0) { + pagesize = sysconf(_SC_PAGE_SIZE); + if (pagesize <= 0) + enprintf(EXIT_FAILURE, "can't determine pagesize\n"); + } fd = open(argv[0], O_RDWR); if (fd < 0)