X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fenv%2F__stack_chk_fail.c;h=031a1ed7058e4aefd498cc4a379858eacc2ac9c2;hp=bbba35118984a24bbb1a335d89abe2b424881309;hb=d432b2c057fc64256645422382c2f7e32c45b3cc;hpb=60872cf9c93687e771c1b8bc41bb006bdcdc2e45 diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c index bbba3511..031a1ed7 100644 --- a/src/env/__stack_chk_fail.c +++ b/src/env/__stack_chk_fail.c @@ -1,11 +1,19 @@ +#include +#include +#include #include "pthread_impl.h" #include "atomic.h" -void __init_ssp(void) +uintptr_t __stack_chk_guard; + +void __init_ssp(void *entropy) { -#ifndef __PIC__ - __pthread_self_init(); -#endif + 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; } void __stack_chk_fail(void)