rt: Account for the size of stack_canary in create_stack
This commit is contained in:
parent
fc028c30a0
commit
dd0ae80e63
@ -13,13 +13,19 @@ struct stk_seg {
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
// A value that goes at the end of the stack and must not be touched
|
||||
const uint8_t stack_canary[] = {0xAB, 0xCD, 0xAB, 0xCD,
|
||||
0xAB, 0xCD, 0xAB, 0xCD,
|
||||
0xAB, 0xCD, 0xAB, 0xCD,
|
||||
0xAB, 0xCD, 0xAB, 0xCD};
|
||||
|
||||
void
|
||||
add_stack_canary(stk_seg *stk);
|
||||
|
||||
template <class T>
|
||||
stk_seg *
|
||||
create_stack(T allocer, size_t sz) {
|
||||
size_t total_sz = sizeof(stk_seg) + sz;
|
||||
size_t total_sz = sizeof(stk_seg) + sz + sizeof(stack_canary);
|
||||
stk_seg *stk = (stk_seg *)allocer->malloc(total_sz, "stack");
|
||||
memset(stk, 0, sizeof(stk_seg));
|
||||
add_stack_canary(stk);
|
||||
|
Loading…
x
Reference in New Issue
Block a user