diff options
author | Steven Moreland <smoreland@google.com> | 2020-01-15 16:49:05 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-01-15 16:49:05 +0000 |
commit | fee43f6e89e94d1a7b3ff2363492f7970cb38c28 (patch) | |
tree | d9c3c8d0147c349a0028585f27ab0d1b67467a4c /tests/stack_protector_test_helper.cpp | |
parent | be64282b8c33751c309b5a4042609a4ee303a4b3 (diff) | |
parent | 06f39d36a4a0d7feb9bce700ef9e0d78b0297219 (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.cpp | 7 |
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'; } |