diff options
| author | Alan Somers <asomers@FreeBSD.org> | 2026-02-17 00:27:02 +0000 |
|---|---|---|
| committer | Alan Somers <asomers@FreeBSD.org> | 2026-02-17 00:27:38 +0000 |
| commit | dc9a8d300ba5c4c319589d78231e9d0e76576cbf (patch) | |
| tree | d269f4f8fe566b9fc2fae1accebadc7991c83cd9 | |
| parent | 05492ff6f636108c4fac40c259defe9b2eac7833 (diff) | |
aio(4) tests: do not rely on (int *)-1 being invalid address
Explicitly mmap guard and use it as the invalid address instead.
MFC after: 1 week
| -rw-r--r-- | tests/sys/aio/aio_test.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c index def8a9d548d6..3f07d9df9810 100644 --- a/tests/sys/aio/aio_test.c +++ b/tests/sys/aio/aio_test.c @@ -39,6 +39,7 @@ #include <sys/param.h> #include <sys/event.h> +#include <sys/mman.h> #include <sys/mdioctl.h> #include <sys/module.h> #include <sys/resource.h> @@ -1665,6 +1666,7 @@ ATF_TC_BODY(aio_writev_efault, tc) struct aiocb aio; ssize_t buflen; char *buffer; + void *unmapped; struct iovec iov[2]; long seed; int fd; @@ -1673,13 +1675,16 @@ ATF_TC_BODY(aio_writev_efault, tc) fd = aio_md_setup(); + unmapped = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_GUARD, -1, 0); + ATF_REQUIRE(unmapped != MAP_FAILED); + seed = random(); buflen = 4096; buffer = malloc(buflen); aio_fill_buffer(buffer, buflen, seed); iov[0].iov_base = buffer; iov[0].iov_len = buflen; - iov[1].iov_base = (void*)-1; /* Invalid! */ + iov[1].iov_base = (void*)unmapped; /* Invalid! */ iov[1].iov_len = buflen; bzero(&aio, sizeof(aio)); aio.aio_fildes = fd; |
