diff options
| author | beck <> | 2016-05-29 20:03:54 +0000 |
|---|---|---|
| committer | beck <> | 2016-05-29 20:03:54 +0000 |
| commit | add66b7a65108b097d758a0b51c8038678703709 (patch) | |
| tree | 4a6b3d1bd12f3649933c766f39c4e2305f6f538a /src | |
| parent | 645ef53477d02b49a87f60de7b5817cd6ee6c760 (diff) | |
| download | openbsd-add66b7a65108b097d758a0b51c8038678703709.tar.gz openbsd-add66b7a65108b097d758a0b51c8038678703709.tar.bz2 openbsd-add66b7a65108b097d758a0b51c8038678703709.zip | |
Nuke sigret.c
ok deraadt@ kettenis@
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libc/sigreturn/Makefile | 18 | ||||
| -rw-r--r-- | src/regress/lib/libc/sigreturn/sigret.c | 180 |
2 files changed, 0 insertions, 198 deletions
diff --git a/src/regress/lib/libc/sigreturn/Makefile b/src/regress/lib/libc/sigreturn/Makefile deleted file mode 100644 index 9891ba9e05..0000000000 --- a/src/regress/lib/libc/sigreturn/Makefile +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.5 2002/09/02 20:01:43 avsm Exp $ | ||
| 2 | |||
| 3 | PROG= sigret | ||
| 4 | |||
| 5 | DEBUG+= -ggdb | ||
| 6 | |||
| 7 | REGRESS_TARGETS+= sigret-normal sigret-indirect sigret-altstack | ||
| 8 | |||
| 9 | sigret-normal: ${PROG} | ||
| 10 | ./${PROG} | ||
| 11 | |||
| 12 | sigret-indirect: ${PROG} | ||
| 13 | ./${PROG} -i | ||
| 14 | |||
| 15 | sigret-altstack: ${PROG} | ||
| 16 | ./${PROG} -a | ||
| 17 | |||
| 18 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/sigreturn/sigret.c b/src/regress/lib/libc/sigreturn/sigret.c deleted file mode 100644 index 2daed9da53..0000000000 --- a/src/regress/lib/libc/sigreturn/sigret.c +++ /dev/null | |||
| @@ -1,180 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * $OpenBSD: sigret.c,v 1.6 2013/12/21 05:17:29 guenther Exp $ | ||
| 3 | * | ||
| 4 | * Public Domain | ||
| 5 | * | ||
| 6 | * Playing games with sigreturn. Check if calling sigreturn from a | ||
| 7 | * signal handler screws anything up. | ||
| 8 | * | ||
| 9 | * Run with: | ||
| 10 | * -a: use an alternate signal stack | ||
| 11 | * | ||
| 12 | * -b: call sigreturn from outside of a signal handler | ||
| 13 | * An error is OK | ||
| 14 | * | ||
| 15 | * -c: clobber the sigcontext before calling sigreturn | ||
| 16 | * the program should die | ||
| 17 | * | ||
| 18 | * -f: don't use sigreturn -- fall through the signal handler | ||
| 19 | * -c, and -i options ignored when used | ||
| 20 | * | ||
| 21 | * -i: call sigreturn from a function called by the signal handler | ||
| 22 | * | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include <sys/time.h> | ||
| 26 | |||
| 27 | #include <err.h> | ||
| 28 | #include <signal.h> | ||
| 29 | #include <stdarg.h> | ||
| 30 | #include <stdio.h> | ||
| 31 | #include <stdlib.h> | ||
| 32 | #include <string.h> | ||
| 33 | #include <unistd.h> | ||
| 34 | |||
| 35 | /* | ||
| 36 | * sigalarm occurs 100 times/second. Stop running after 5 seconds | ||
| 37 | */ | ||
| 38 | #define MAX_INTERRUPTS 500 | ||
| 39 | |||
| 40 | int failed; | ||
| 41 | int altstack; | ||
| 42 | int badcall; | ||
| 43 | int clobbercall; | ||
| 44 | int fallthru; | ||
| 45 | int indirect; | ||
| 46 | |||
| 47 | volatile int count; | ||
| 48 | struct sigcontext gscp; | ||
| 49 | int gscp_loaded; | ||
| 50 | |||
| 51 | static void | ||
| 52 | usage(const char * err, ...) | ||
| 53 | { | ||
| 54 | extern const char * __progname; | ||
| 55 | |||
| 56 | if (err) { | ||
| 57 | va_list ap; | ||
| 58 | va_start(ap, err); | ||
| 59 | vwarnx(err, ap); | ||
| 60 | va_end(ap); | ||
| 61 | } | ||
| 62 | fprintf(stderr, "usage: %s [-abcfi]\n", __progname); | ||
| 63 | exit(1); | ||
| 64 | } | ||
| 65 | |||
| 66 | static void | ||
| 67 | indirect_return(struct sigcontext * scp) | ||
| 68 | { | ||
| 69 | sigreturn(scp); | ||
| 70 | } | ||
| 71 | |||
| 72 | static void | ||
| 73 | sig_handler(int sig, siginfo_t *blah, void *x) | ||
| 74 | { | ||
| 75 | struct sigcontext * scp = x; | ||
| 76 | |||
| 77 | count++; | ||
| 78 | |||
| 79 | if (!fallthru) { | ||
| 80 | if (clobbercall) | ||
| 81 | memset(scp, 0, sizeof *scp); | ||
| 82 | if (indirect) | ||
| 83 | indirect_return(scp); | ||
| 84 | else if (badcall) { | ||
| 85 | gscp = *scp; | ||
| 86 | gscp_loaded = 1; | ||
| 87 | } else | ||
| 88 | sigreturn(scp); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | static void | ||
| 93 | test2(char *fmt) | ||
| 94 | { | ||
| 95 | char *ofmt = fmt; | ||
| 96 | |||
| 97 | if (gscp_loaded) { | ||
| 98 | gscp_loaded = 0; | ||
| 99 | sigreturn(&gscp); | ||
| 100 | } | ||
| 101 | |||
| 102 | for (; *fmt; fmt++) | ||
| 103 | switch (*fmt) { | ||
| 104 | case 'i': | ||
| 105 | case 'c': | ||
| 106 | case 'l': | ||
| 107 | case 'p': | ||
| 108 | break; | ||
| 109 | default: | ||
| 110 | failed = 1; | ||
| 111 | fprintf(stderr, | ||
| 112 | "unexpected character 0x%02x `%c' in %s: count %d\n", | ||
| 113 | *fmt, *fmt, ofmt, count); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | int | ||
| 118 | main(int argc, char * argv[]) | ||
| 119 | { | ||
| 120 | extern char *optarg; | ||
| 121 | extern int optind; | ||
| 122 | |||
| 123 | int opt; | ||
| 124 | |||
| 125 | struct sigaction act; | ||
| 126 | struct sigaltstack ss; | ||
| 127 | |||
| 128 | while ((opt = getopt(argc, argv, "abcfi")) != -1) { | ||
| 129 | switch (opt) { | ||
| 130 | case 'a': | ||
| 131 | /* use sigaltstack */ | ||
| 132 | altstack = 1; | ||
| 133 | break; | ||
| 134 | case 'b': | ||
| 135 | /* call outside of sig_handler */ | ||
| 136 | badcall = 1; | ||
| 137 | break; | ||
| 138 | case 'c': | ||
| 139 | /* force error by munging sigcontext */ | ||
| 140 | clobbercall = 1; | ||
| 141 | break; | ||
| 142 | case 'f': | ||
| 143 | /* don't use sigreturn */ | ||
| 144 | fallthru = 1; | ||
| 145 | break; | ||
| 146 | case 'i': | ||
| 147 | /* call sigreturn indirectly */ | ||
| 148 | indirect = 1; | ||
| 149 | break; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | /* make sure there is no other cruft left on the command line */ | ||
| 154 | if (optind != argc) | ||
| 155 | usage("unknown argument -- %s", argv[ optind ]); | ||
| 156 | |||
| 157 | if (altstack) { | ||
| 158 | if ((ss.ss_sp = malloc(SIGSTKSZ)) == NULL) | ||
| 159 | errx(1, "ss_sp malloc"); | ||
| 160 | |||
| 161 | ss.ss_size = SIGSTKSZ; | ||
| 162 | ss.ss_flags = 0; | ||
| 163 | if (sigaltstack(&ss,0) == -1) | ||
| 164 | err(1, "sigaltstack"); | ||
| 165 | } | ||
| 166 | |||
| 167 | sigfillset(&act.sa_mask); | ||
| 168 | act.sa_sigaction = sig_handler; | ||
| 169 | act.sa_flags = SA_RESTART; | ||
| 170 | if (altstack) | ||
| 171 | act.sa_flags |= SA_ONSTACK; | ||
| 172 | sigaction(SIGALRM, &act, NULL); | ||
| 173 | |||
| 174 | ualarm(10000, 10000); | ||
| 175 | |||
| 176 | while (count < MAX_INTERRUPTS) | ||
| 177 | test2("iclp"); | ||
| 178 | |||
| 179 | return failed; | ||
| 180 | } | ||
