[hackers] [ubase] Check for a valid pagesize in mkswap(8) || sin

From: <git_AT_suckless.org>
Date: Tue, 29 Oct 2013 16:56:03 +0100

commit 41769b976a17a5704cfc0ae27d1ec72c54fbf52e
Author: sin <sin_AT_2f30.org>
Date: Tue Oct 29 15:54:12 2013 +0000

    Check for a valid pagesize in mkswap(8)

diff --git a/mkswap.c b/mkswap.c
index 40522fa..31a83a4 100644
--- a/mkswap.c
+++ b/mkswap.c
_AT_@ -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
");
+ }
 
         fd = open(argv[0], O_RDWR);
         if (fd < 0)
Received on Tue Oct 29 2013 - 16:56:03 CET

This archive was generated by hypermail 2.3.0 : Tue Oct 29 2013 - 17:00:21 CET