diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-26 23:30:43 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-26 23:30:43 +0000 |
commit | 086e525f6530f82efbd6c0fb019b5f8b7d964c3e (patch) | |
tree | 4dfd09294ef75c0bcca964d290e34cb46e2042be | |
parent | 593989ca06e239c26d8b2fe773d4e69a53195c5b (diff) |
ensure that bss object being used is not ... inside the last page of data.
a.out ZMAGIC permits that to happen. so we need to pad it over, for the
test to work.
-rw-r--r-- | regress/sys/kern/nxbss/nxbss.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/regress/sys/kern/nxbss/nxbss.c b/regress/sys/kern/nxbss/nxbss.c index 5e6d5ef7c50..e7fd7b8250a 100644 --- a/regress/sys/kern/nxbss/nxbss.c +++ b/regress/sys/kern/nxbss/nxbss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nxbss.c,v 1.1 2002/07/26 01:20:44 deraadt Exp $ */ +/* $OpenBSD: nxbss.c,v 1.2 2002/07/26 23:30:42 deraadt Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -28,11 +28,15 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/types.h> +#include <sys/mman.h> #include <stdio.h> #include <signal.h> #include <string.h> -u_int64_t buf[256]; /* assuming the testfly() will fit */ +#define PAD 64*1024 +#define TEST 256 +u_int64_t buf[PAD+TEST]; /* assuming the testfly() will fit */ void testfly() @@ -48,8 +52,10 @@ sigsegv(int sig) int main(void) { + void *p = &buf[PAD]; signal(SIGSEGV, sigsegv); - memcpy(buf, &testfly, sizeof(buf)); - ((void (*)(void))&buf)(); + + memcpy(p, &testfly, TEST); + ((void (*)(void))p)(); exit(1); } |