diff options
author | dhartmei <> | 2002-08-30 07:58:08 +0000 |
---|---|---|
committer | dhartmei <> | 2002-08-30 07:58:08 +0000 |
commit | b317bf50a10ff572164977749e56454ad595e904 (patch) | |
tree | 51557b2bbef0a3aa7dfeb77c6f8962aff1d6a489 /src/lib/libc/stdlib/exit.c | |
parent | 509a5b94525f34212cd48bccbf85481897ecd99f (diff) | |
download | openbsd-b317bf50a10ff572164977749e56454ad595e904.tar.gz openbsd-b317bf50a10ff572164977749e56454ad595e904.tar.bz2 openbsd-b317bf50a10ff572164977749e56454ad595e904.zip |
re-enable function pointer table protection, this time make sure that
malloc.c gets the first mmap() call (since it depends on that, for its
sbrk(0) use). ok deraadt@
Diffstat (limited to 'src/lib/libc/stdlib/exit.c')
-rw-r--r-- | src/lib/libc/stdlib/exit.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c index 0bf0d3a180..c69639125e 100644 --- a/src/lib/libc/stdlib/exit.c +++ b/src/lib/libc/stdlib/exit.c | |||
@@ -32,9 +32,11 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char *rcsid = "$OpenBSD: exit.c,v 1.6 2002/07/31 18:13:16 dhartmei Exp $"; | 35 | static char *rcsid = "$OpenBSD: exit.c,v 1.7 2002/08/30 07:58:07 dhartmei Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <sys/types.h> | ||
39 | #include <sys/mman.h> | ||
38 | #include <stdlib.h> | 40 | #include <stdlib.h> |
39 | #include <unistd.h> | 41 | #include <unistd.h> |
40 | #include "atexit.h" | 42 | #include "atexit.h" |
@@ -58,12 +60,19 @@ void | |||
58 | exit(status) | 60 | exit(status) |
59 | int status; | 61 | int status; |
60 | { | 62 | { |
61 | register struct atexit *p; | 63 | register struct atexit *p, *q; |
62 | register int n; | 64 | register int n, pgsize = getpagesize(); |
63 | 65 | ||
64 | for (p = __atexit; p; p = p->next) | 66 | if (!__atexit_invalid) { |
65 | for (n = p->ind; --n >= 0;) | 67 | p = __atexit; |
66 | (*p->fns[n])(); | 68 | while (p != NULL) { |
69 | for (n = p->ind; --n >= 0;) | ||
70 | (*p->fns[n])(); | ||
71 | q = p; | ||
72 | p = p->next; | ||
73 | munmap(q, pgsize); | ||
74 | } | ||
75 | } | ||
67 | if (__cleanup) | 76 | if (__cleanup) |
68 | (*__cleanup)(); | 77 | (*__cleanup)(); |
69 | _exit(status); | 78 | _exit(status); |