X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fenv%2F__stack_chk_fail.c;h=e32596d10fff84a89a73cab4c0d84c26101769af;hb=d88e5dfa8b989dafff4b748bfb3cba3512c8482e;hp=eac852b7a39572e9b10bfd1df3a2488c0a52ba39;hpb=731e8ffdcf6877c04092aa9fbd2b17907b8846c7;p=musl diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c index eac852b7..e32596d1 100644 --- a/src/env/__stack_chk_fail.c +++ b/src/env/__stack_chk_fail.c @@ -1,24 +1,22 @@ #include -#include -#include +#include #include "pthread_impl.h" -#include "atomic.h" uintptr_t __stack_chk_guard; -void __init_ssp(size_t *auxv) +void __init_ssp(void *entropy) { - size_t i; - pthread_t self = __pthread_self_init(); - uintptr_t canary; - for (i=0; auxv[i] && auxv[i]!=AT_RANDOM; i+=2); - if (auxv[i]) memcpy(&canary, (void *)auxv[i+1], 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; + + __pthread_self()->CANARY = __stack_chk_guard; } void __stack_chk_fail(void) { a_crash(); } + +hidden void __stack_chk_fail_local(void); + +weak_alias(__stack_chk_fail, __stack_chk_fail_local);