summaryrefslogtreecommitdiff
path: root/test/badsalt.c
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2021-08-04 12:20:46 +0200
committerBjörn Esser <besser82@fedoraproject.org>2021-08-04 12:26:06 +0200
commitd224426a5aba4b5d4c212e5e6b16e44b77f649cb (patch)
treed5de030e0aa557052b677ace738bc5b82d34e14b /test/badsalt.c
parenta59f32e9ee0e4e2c24e63af722bbdb3bdb142e90 (diff)
downloadlibxcrypt-d224426a5aba4b5d4c212e5e6b16e44b77f649cb.tar.gz
libxcrypt-d224426a5aba4b5d4c212e5e6b16e44b77f649cb.tar.bz2
libxcrypt-d224426a5aba4b5d4c212e5e6b16e44b77f649cb.zip
test/badsalt.c: Fix 'NEGATIVE_RETURNS' found by Covscan.
CWE-687: Argument cannot be negative (NEGATIVE_RETURNS) negative_returns: pagesize is passed to a parameter that cannot be negative.
Diffstat (limited to 'test/badsalt.c')
-rw-r--r--test/badsalt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/badsalt.c b/test/badsalt.c
index ecad067..ccf2d6c 100644
--- a/test/badsalt.c
+++ b/test/badsalt.c
@@ -662,13 +662,14 @@ main (int argc, char **argv)
/* Set up a two-page region whose first page is read-write and
whose second page is inaccessible. */
- size_t pagesize = (size_t) sysconf (_SC_PAGESIZE);
- if (pagesize < CRYPT_OUTPUT_SIZE)
+ long pagesize_l = sysconf (_SC_PAGESIZE);
+ if (pagesize_l < (long) CRYPT_OUTPUT_SIZE)
{
- printf ("ERROR: pagesize of %zu is too small\n", pagesize);
+ printf ("ERROR: pagesize of %ld is too small\n", pagesize_l);
return 99;
}
+ size_t pagesize = (size_t) pagesize_l;
char *page = mmap (0, pagesize * 2, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANON, -1, 0);
if (page == MAP_FAILED)