Page MenuHomeFreeBSD

D46954.diff
No OneTemporary

D46954.diff

diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
--- a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
@@ -103,9 +103,7 @@
unsigned long vmin = 0;
size_t len = sizeof(vmin);
#endif
-#if !defined(__aarch64__) && !defined(__riscv)
void *invalid_ptr;
-#endif
void *buf;
#ifdef __FreeBSD__
@@ -159,13 +157,14 @@
#endif
(void)free(buf);
-/* There is no sbrk on AArch64 and RISC-V */
-#if !defined(__aarch64__) && !defined(__riscv)
/*
- * Try to create a pointer to an unmapped page - first after current
- * brk will likely do.
+ * Try to create a pointer to an unmapped page - mmap and then
+ * munmap a page.
*/
- invalid_ptr = (void*)(((uintptr_t)sbrk(0)+page) & ~(page-1));
+ invalid_ptr = mmap(NULL, page, PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0);
+ ATF_REQUIRE(invalid_ptr != MAP_FAILED);
+ ATF_REQUIRE(munmap(invalid_ptr, page) == 0);
printf("testing with (hopefully) invalid pointer %p\n", invalid_ptr);
errno = 0;
@@ -173,7 +172,6 @@
errno = 0;
ATF_REQUIRE_ERRNO(ENOMEM, munlock(invalid_ptr, page) == -1);
-#endif
}
#ifdef __FreeBSD__

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 6, 7:30 AM (22 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13686951
Default Alt Text
D46954.diff (1 KB)

Event Timeline