summaryrefslogtreecommitdiff
path: root/tests/stack_protector_test_helper.cpp
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2020-01-15 16:49:05 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-01-15 16:49:05 +0000
commitfee43f6e89e94d1a7b3ff2363492f7970cb38c28 (patch)
treed9c3c8d0147c349a0028585f27ab0d1b67467a4c /tests/stack_protector_test_helper.cpp
parentbe64282b8c33751c309b5a4042609a4ee303a4b3 (diff)
parent06f39d36a4a0d7feb9bce700ef9e0d78b0297219 (diff)
Merge "stack_protector_DeathTest: work w/ local reorder"
Diffstat (limited to 'tests/stack_protector_test_helper.cpp')
-rw-r--r--tests/stack_protector_test_helper.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/stack_protector_test_helper.cpp b/tests/stack_protector_test_helper.cpp
index 2db4ef142..fd90b939b 100644
--- a/tests/stack_protector_test_helper.cpp
+++ b/tests/stack_protector_test_helper.cpp
@@ -16,11 +16,10 @@
// Deliberately overwrite the stack canary.
__attribute__((noinline)) void modify_stack_protector_test() {
- char buf[128];
// We can't use memset here because it's fortified, and we want to test
// the line of defense *after* that.
// Without volatile, the generic x86/x86-64 targets don't write to the stack.
- volatile char* p = buf;
- int size = static_cast<int>(sizeof(buf) + sizeof(void*));
- while ((p - buf) < size) *p++ = '\0';
+ volatile char* p;
+ p = reinterpret_cast<volatile char*>(&p + 1);
+ *p = '\0';
}