1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 18:07:35 +00:00

LibC: Use uintptr_t for __stack_chk_guard

We used size_t, which is a type that is guarenteed to be large
enough to hold an array index, but uintptr_t is designed to be used
to hold pointer values, which is the case of stack guards.
This commit is contained in:
Keegan Saunders 2022-11-26 13:17:32 -05:00 committed by Andreas Kling
parent 675e5bfdce
commit 89b23c473a
6 changed files with 11 additions and 11 deletions

View file

@ -14,7 +14,7 @@
#ifndef _DYNAMIC_LOADER
extern "C" {
extern size_t __stack_chk_guard;
extern uintptr_t __stack_chk_guard;
extern bool s_global_initializers_ran;
int main(int, char**, char**);

View file

@ -17,8 +17,8 @@
extern "C" {
extern size_t __stack_chk_guard;
__attribute__((used)) size_t __stack_chk_guard = (size_t)0xc6c7c8c9;
extern uintptr_t __stack_chk_guard;
__attribute__((used)) uintptr_t __stack_chk_guard = (uintptr_t)0xc6c7c8c9;
__attribute__((noreturn)) void __stack_chk_fail()
{

View file

@ -258,7 +258,7 @@ static void initialize_libc(DynamicObject& libc)
// This is not done in __libc_init, as we definitely have to return from that, and it might affect Loader as well.
res = libc.lookup_symbol("__stack_chk_guard"sv);
VERIFY(res.has_value());
arc4random_buf(res.value().address.as_ptr(), sizeof(size_t));
arc4random_buf(res.value().address.as_ptr(), sizeof(uintptr_t));
res = libc.lookup_symbol("__environ_is_malloced"sv);
VERIFY(res.has_value());