summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/findfp.c
diff options
context:
space:
mode:
authordhartmei <dhartmei@openbsd.org>2002-09-14 22:03:14 +0000
committerdhartmei <dhartmei@openbsd.org>2002-09-14 22:03:14 +0000
commit8d62ee40dc28d335867f292dd8aab66f53e20b5b (patch)
treead54f039e1d7d49a8f9d2f8fe09f8b447e2e743f /lib/libc/stdio/findfp.c
parentrecognize AppleKiwi (diff)
downloadwireguard-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/stdio/findfp.c')
-rw-r--r--lib/libc/stdio/findfp.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c
index 0702efad985..3aa66965367 100644
--- a/lib/libc/stdio/findfp.c
+++ b/lib/libc/stdio/findfp.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: findfp.c,v 1.2 1996/08/19 08:32:36 tholo Exp $";
+static char rcsid[] = "$OpenBSD: findfp.c,v 1.3 2002/09/14 22:03:14 dhartmei Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -141,9 +141,10 @@ f_prealloc()
}
/*
- * exit() calls _cleanup() through *__cleanup, set whenever we
- * open or buffer a file. This chicanery is done so that programs
- * that do not use stdio need not link it all in.
+ * exit() and abort() call _cleanup() through the callback registered
+ * with __atexit_register_cleanup(), set whenever we open or buffer a
+ * file. This chicanery is done so that programs that do not use stdio
+ * need not link it all in.
*
* The name `_cleanup' is, alas, fairly well known outside stdio.
*/
@@ -161,6 +162,6 @@ void
__sinit()
{
/* make sure we clean up on exit */
- __cleanup = _cleanup; /* conservative */
+ __atexit_register_cleanup(_cleanup); /* conservative */
__sdidinit = 1;
}