diff options
Diffstat (limited to 'src/rt/rust_stack.h')
| -rw-r--r-- | src/rt/rust_stack.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rt/rust_stack.h b/src/rt/rust_stack.h index 6d5fea0c7ef..190cfba8c13 100644 --- a/src/rt/rust_stack.h +++ b/src/rt/rust_stack.h @@ -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); |
