summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/exit.c
diff options
context:
space:
mode:
authorDaniel Hartmeier <dhartmei@cvs.openbsd.org>2002-08-30 07:58:09 +0000
committerDaniel Hartmeier <dhartmei@cvs.openbsd.org>2002-08-30 07:58:09 +0000
commit9b39efd26684f6089987d8c4ff0977764a7828a3 (patch)
treeb971b3bf5bd7d83c1398c6a8f849c3eb10a017d0 /lib/libc/stdlib/exit.c
parentfe561522dd072de9e9fba92b0958a0a3431e0a95 (diff)
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.c21
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);