master
 1#include <string.h>
 2#include <stdint.h>
 3#include "pthread_impl.h"
 4
 5uintptr_t __stack_chk_guard;
 6
 7void __init_ssp(void *entropy)
 8{
 9	if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
10	else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
11
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
20
21	__pthread_self()->canary = __stack_chk_guard;
22}
23
24void __stack_chk_fail(void)
25{
26	a_crash();
27}
28
29hidden void __stack_chk_fail_local(void);
30
31weak_alias(__stack_chk_fail, __stack_chk_fail_local);