diff options
author | 2002-09-14 22:03:14 +0000 | |
---|---|---|
committer | 2002-09-14 22:03:14 +0000 | |
commit | 8d62ee40dc28d335867f292dd8aab66f53e20b5b (patch) | |
tree | ad54f039e1d7d49a8f9d2f8fe09f8b447e2e743f /lib/libc/stdlib/exit.c | |
parent | recognize AppleKiwi (diff) | |
download | wireguard-openbsd-8d62ee40dc28d335867f292dd8aab66f53e20b5b.tar.xz wireguard-openbsd-8d62ee40dc28d335867f292dd8aab66f53e20b5b.zip |
Move __cleanup into mprotect'ed page to prevent unintentional modifications
similar to the atexit handlers. Idea and help deraadt@, ok deraadt@
Diffstat (limited to 'lib/libc/stdlib/exit.c')
-rw-r--r-- | lib/libc/stdlib/exit.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index c69639125ef..e22bd5178e6 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: exit.c,v 1.7 2002/08/30 07:58:07 dhartmei Exp $"; +static char *rcsid = "$OpenBSD: exit.c,v 1.8 2002/09/14 22:03:14 dhartmei Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -42,8 +42,6 @@ static char *rcsid = "$OpenBSD: exit.c,v 1.7 2002/08/30 07:58:07 dhartmei Exp $" #include "atexit.h" #include "thread_private.h" -void (*__cleanup)(); - /* * This variable is zero until a process has created a thread. * It is used to avoid calling locking functions in libc when they @@ -67,13 +65,13 @@ exit(status) p = __atexit; while (p != NULL) { for (n = p->ind; --n >= 0;) - (*p->fns[n])(); + if (p->fns[n] != NULL) + (*p->fns[n])(); q = p; p = p->next; munmap(q, pgsize); } } - if (__cleanup) - (*__cleanup)(); + /* cleanup, if registered, was called through fns[0] in the last page */ _exit(status); } |