Changeset View
Changeset View
Standalone View
Standalone View
libexec/rtld-elf/rtld.c
| Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | if (auxp->a_type < AT_COUNT) | ||||
| main_argc = argc; | main_argc = argc; | ||||
| main_argv = argv; | main_argv = argv; | ||||
| if (aux_info[AT_CANARY] != NULL && | if (aux_info[AT_CANARY] != NULL && | ||||
| aux_info[AT_CANARY]->a_un.a_ptr != NULL) { | aux_info[AT_CANARY]->a_un.a_ptr != NULL) { | ||||
| i = aux_info[AT_CANARYLEN]->a_un.a_val; | i = aux_info[AT_CANARYLEN]->a_un.a_val; | ||||
| if (i > sizeof(__stack_chk_guard)) | if (i > sizeof(__stack_chk_guard)) | ||||
| i = sizeof(__stack_chk_guard); | i = sizeof(__stack_chk_guard); | ||||
| memcpy(__stack_chk_guard, aux_info[AT_CANARY]->a_un.a_ptr, i); | |||||
| /* | |||||
| * Avoid using functions which might have stack protection | |||||
| * enabled, to update the __stack_chk_guard. | |||||
| * Do a manual volatile copy to not allow the optimizer to | |||||
| * call memcpy() behind us. | |||||
| */ | |||||
| while (--i >= 0) { | |||||
| ((char *)__stack_chk_guard)[i] = ((volatile char *)(aux_info[AT_CANARY]->a_un.a_ptr))[i]; | |||||
| } | |||||
| } else { | } else { | ||||
| mib[0] = CTL_KERN; | mib[0] = CTL_KERN; | ||||
| mib[1] = KERN_ARND; | mib[1] = KERN_ARND; | ||||
| len = sizeof(__stack_chk_guard); | len = sizeof(__stack_chk_guard); | ||||
| if (sysctl(mib, 2, __stack_chk_guard, &len, NULL, 0) == -1 || | if (sysctl(mib, 2, __stack_chk_guard, &len, NULL, 0) == -1 || | ||||
| len != sizeof(__stack_chk_guard)) { | len != sizeof(__stack_chk_guard)) { | ||||
| /* If sysctl was unsuccessful, use the "terminator canary". */ | /* If sysctl was unsuccessful, use the "terminator canary". */ | ||||
| ▲ Show 20 Lines • Show All 5,149 Lines • Show Last 20 Lines | |||||