Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Don't rely on INT_MAX being unmapped. Us...
details: https://anonhg.NetBSD.org/src/rev/bab123f458a9
branches: trunk
changeset: 778098:bab123f458a9
user: matt <matt%NetBSD.org@localhost>
date: Fri Mar 16 06:15:17 2012 +0000
description:
Don't rely on INT_MAX being unmapped. Use mmap to get a page and then unmap
it. Then use that address for msync.
diffstat:
tests/lib/libc/sys/t_msync.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diffs (45 lines):
diff -r 13818a245ff7 -r bab123f458a9 tests/lib/libc/sys/t_msync.c
--- a/tests/lib/libc/sys/t_msync.c Fri Mar 16 05:43:09 2012 +0000
+++ b/tests/lib/libc/sys/t_msync.c Fri Mar 16 06:15:17 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msync.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */
+/* $NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_msync.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $");
+__RCSID("$NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $");
#include <sys/mman.h>
@@ -165,6 +165,8 @@
ATF_TC_BODY(msync_err, tc)
{
+ char *map = MAP_FAILED;
+
/*
* Test that invalid flags error out.
*/
@@ -173,7 +175,16 @@
errno = 0;
- ATF_REQUIRE(msync((void *)INT_MAX, page, MS_SYNC) != 0);
+ /*
+ * Map a page and then unmap to get an unmapped address.
+ */
+ map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
+ -1, 0);
+ ATF_REQUIRE(map != MAP_FAILED);
+
+ (void)munmap(map, page);
+
+ ATF_REQUIRE(msync(map, page, MS_SYNC) != 0);
ATF_REQUIRE(errno == EFAULT);
}
Home |
Main Index |
Thread Index |
Old Index