syslog: revert LOG_FAC/LOG_FACMASK changes
[musl.git] / src / env / __stack_chk_fail.c
blobe53526020f751d34542f07c6b30d94c5dc08bf72
1 #include <string.h>
2 #include <stdint.h>
3 #include "pthread_impl.h"
5 uintptr_t __stack_chk_guard;
7 void __init_ssp(void *entropy)
9 if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
10 else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
12 #if UINTPTR_MAX >= 0xffffffffffffffff
13 /* Sacrifice 8 bits of entropy on 64bit to prevent leaking/
14 * overwriting the canary via string-manipulation functions.
15 * The NULL byte is on the second byte so that off-by-ones can
16 * still be detected. Endianness is taken care of
17 * automatically. */
18 ((char *)&__stack_chk_guard)[1] = 0;
19 #endif
21 __pthread_self()->canary = __stack_chk_guard;
24 void __stack_chk_fail(void)
26 a_crash();
29 hidden void __stack_chk_fail_local(void);
31 weak_alias(__stack_chk_fail, __stack_chk_fail_local);