X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fenv%2F__stack_chk_fail.c;h=87ac473d1096f97ff0e062a6b532543d4ea3e1f4;hb=3f65494a4cb2544eb16af3fa64a161bd8142f487;hp=031a1ed7058e4aefd498cc4a379858eacc2ac9c2;hpb=3a5aa8e49ce9a98725ceb311bb64f6168fc72d3e;p=musl diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c index 031a1ed7..87ac473d 100644 --- a/src/env/__stack_chk_fail.c +++ b/src/env/__stack_chk_fail.c @@ -1,19 +1,16 @@ #include -#include -#include +#include #include "pthread_impl.h" -#include "atomic.h" uintptr_t __stack_chk_guard; void __init_ssp(void *entropy) { - pthread_t self = __pthread_self_init(); - uintptr_t canary; - if (entropy) memcpy(&canary, entropy, sizeof canary); - else canary = (uintptr_t)&canary * 1103515245; - a_cas_l(&__stack_chk_guard, 0, canary); - self->canary = __stack_chk_guard; + if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t)); + else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245; + + if (libc.has_thread_pointer) + __pthread_self()->canary = __stack_chk_guard; } void __stack_chk_fail(void)