libroot: Fix bad pointer access in __init_stack_protector

The address of the variable should be taken instead of the
variable itself being casted to `void*`.

This fixes a rare segfault bug when any Haiku binary runs in
a `chroot`ed environment without a `/dev` mount.

Change-Id: I2fdacac62fadbcce8006bbf0a5350f6ec95133ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6377
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Trung Nguyen
2023-04-16 15:57:12 +00:00
committed by Adrien Destugues
parent 50a5eed083
commit 7bfc9c6fc7
+5 -4
View File
@@ -32,10 +32,11 @@ __init_stack_protector()
}
if (!done) {
((unsigned char *)(void *)__stack_chk_guard)[0] = 0;
((unsigned char *)(void *)__stack_chk_guard)[1] = 0;
((unsigned char *)(void *)__stack_chk_guard)[2] = '\n';
((unsigned char *)(void *)__stack_chk_guard)[3] = 0xff;
unsigned char* p = (unsigned char *)&__stack_chk_guard;
p[0] = 0;
p[1] = 0;
p[2] = '\n';
p[3] = 0xff;
}
}