diff options
author | hrs <hrs@FreeBSD.org> | 2011-05-29 02:53:52 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2011-05-29 02:53:52 +0000 |
commit | 8fe640108653f13042f1b15213769e338aa524f6 (patch) | |
tree | 91f5675a7c792e61d68635707501027daa3f566f /lib/libc/sys/stack_protector.c | |
parent | 97f64b711efa9ff0011bef5d46cf9645638a38f9 (diff) | |
parent | f3726238c8e8206eb1df4cfaf3f00947ceba3cce (diff) | |
download | FreeBSD-src-8fe640108653f13042f1b15213769e338aa524f6.zip FreeBSD-src-8fe640108653f13042f1b15213769e338aa524f6.tar.gz |
Merge from head@222434.
Diffstat (limited to 'lib/libc/sys/stack_protector.c')
-rw-r--r-- | lib/libc/sys/stack_protector.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index 14c20eb..ed7d635 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* $NetBSD: stack_protector.c,v 1.4 2006/11/22 17:23:25 christos Exp $ */ /* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */ /* @@ -34,10 +33,13 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/sysctl.h> #include <sys/types.h> +#include <errno.h> +#include <link.h> #include <signal.h> #include <string.h> #include <syslog.h> #include <unistd.h> +#include "libc_private.h" extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); @@ -54,9 +56,14 @@ __guard_setup(void) { int mib[2]; size_t len; + int error; if (__stack_chk_guard[0] != 0) return; + error = _elf_aux_info(AT_CANARY, __stack_chk_guard, + sizeof(__stack_chk_guard)); + if (error == 0 && __stack_chk_guard[0] != 0) + return; mib[0] = CTL_KERN; mib[1] = KERN_ARND; @@ -85,7 +92,7 @@ __fail(const char *msg) (void)sigprocmask(SIG_BLOCK, &mask, NULL); /* This may fail on a chroot jail... */ - syslog(LOG_CRIT, msg); + syslog(LOG_CRIT, "%s", msg); (void)memset(&sa, 0, sizeof(sa)); (void)sigemptyset(&sa.sa_mask); @@ -108,8 +115,6 @@ __chk_fail(void) __fail("buffer overflow detected; terminated"); } -#ifdef PIC -__sym_compat(__stack_chk_fail_local, __stack_chk_fail, FBSD_1.0); -#else +#ifndef PIC __weak_reference(__stack_chk_fail, __stack_chk_fail_local); #endif |