diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-07-01 18:15:52 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-07-01 18:15:52 +0000 |
commit | 19682fa3d8e13fc94286ca2aa8ac87030bf8eda2 (patch) | |
tree | 796b0d662ac0bf755f639ffe5b33c3d973a869e3 /regress/sys/kern/nxstack/nxstack.c | |
parent | 5b599e0094027239ac02006e286e1edf947b8de2 (diff) |
a test to see if stack is executable
Diffstat (limited to 'regress/sys/kern/nxstack/nxstack.c')
-rw-r--r-- | regress/sys/kern/nxstack/nxstack.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/regress/sys/kern/nxstack/nxstack.c b/regress/sys/kern/nxstack/nxstack.c new file mode 100644 index 00000000000..d8584c1dae7 --- /dev/null +++ b/regress/sys/kern/nxstack/nxstack.c @@ -0,0 +1,54 @@ +/* $OpenBSD: nxstack.c,v 1.1 2002/07/01 18:15:51 mickey Exp $ */ + +/* + * Copyright (c) 2002 Michael Shalayeff + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <signal.h> + +void +testfly() +{ +} + +void +sigsegv(int sig) +{ + _exit(0); +} + +int +main(void) +{ + u_int64_t buf[256]; /* assuming the testfly() will fit */ + + signal(SIGSEGV, sigsegv); + memcpy(buf, &testfly, sizeof(buf)); + ((void (*)(void))&buf)(); + exit(1); +} |