Fix stack-protector.rs on LLVM 17
Prevent fill from being (correctly) optimized away by passing the address of the alloca to black_box.
This commit is contained in:
parent
ad7ea8b7e6
commit
01cdc505d9
@ -40,6 +40,8 @@ fn vulnerable_function() {
|
||||
// Overwrite the on-stack return address with the address of `malicious_code()`,
|
||||
// thereby jumping to that function when returning from `vulnerable_function()`.
|
||||
unsafe { fill(stackaddr, bad_code_ptr, 20); }
|
||||
// Capture the address, so the write is not optimized away.
|
||||
std::hint::black_box(stackaddr);
|
||||
}
|
||||
|
||||
// Use an uninlined function with its own stack frame to make sure that we don't
|
||||
|
Loading…
Reference in New Issue
Block a user