diff options
author | 2002-08-30 07:58:07 +0000 | |
---|---|---|
committer | 2002-08-30 07:58:07 +0000 | |
commit | 2762c2ed51f84d6c1fa091d0fc24b67155fed1e3 (patch) | |
tree | 98774455bc79e53676420e45933cb444cec30357 /lib/libc/stdlib/exit.c | |
parent | have -I option, which causes traceroute6 to use ICMPv6 echo request for probing (diff) | |
download | wireguard-openbsd-2762c2ed51f84d6c1fa091d0fc24b67155fed1e3.tar.xz wireguard-openbsd-2762c2ed51f84d6c1fa091d0fc24b67155fed1e3.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 'lib/libc/stdlib/exit.c')
-rw-r--r-- | lib/libc/stdlib/exit.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 0bf0d3a1808..c69639125ef 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -32,9 +32,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: exit.c,v 1.6 2002/07/31 18:13:16 dhartmei Exp $"; +static char *rcsid = "$OpenBSD: exit.c,v 1.7 2002/08/30 07:58:07 dhartmei Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/types.h> +#include <sys/mman.h> #include <stdlib.h> #include <unistd.h> #include "atexit.h" @@ -58,12 +60,19 @@ void exit(status) int status; { - register struct atexit *p; - register int n; + register struct atexit *p, *q; + register int n, pgsize = getpagesize(); - for (p = __atexit; p; p = p->next) - for (n = p->ind; --n >= 0;) - (*p->fns[n])(); + if (!__atexit_invalid) { + p = __atexit; + while (p != NULL) { + for (n = p->ind; --n >= 0;) + (*p->fns[n])(); + q = p; + p = p->next; + munmap(q, pgsize); + } + } if (__cleanup) (*__cleanup)(); _exit(status); |