summaryrefslogtreecommitdiff
path: root/tests/stack_protector_test_helper.cpp
diff options
context:
space:
mode:
authorAndy Quan <andyq@google.com>2023-06-02 14:49:35 -0700
committerAndy Quan <andyq@google.com>2023-06-02 14:49:35 -0700
commitbd751238fade1f933deefdb34ba13fc8f868646b (patch)
tree1ff3736c7ff7a0a1d384207257fe8d16efd49bc0 /tests/stack_protector_test_helper.cpp
parent129a265ab9467876da85d6162558d348cdf0ba7c (diff)
parente2b2fd5475b5da5866e481bd5b72ef4333032792 (diff)
DO NOT MERGE - Merge tm-qpr3-release TQ3A.230605.010 into tm-platform-merge
Bug: 279962103 Change-Id: Icc5770772d20fd701183efbdbf7855497483a2cd
Diffstat (limited to 'tests/stack_protector_test_helper.cpp')
-rw-r--r--tests/stack_protector_test_helper.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/stack_protector_test_helper.cpp b/tests/stack_protector_test_helper.cpp
index fd90b939b..eddd94074 100644
--- a/tests/stack_protector_test_helper.cpp
+++ b/tests/stack_protector_test_helper.cpp
@@ -19,7 +19,8 @@ __attribute__((noinline)) void modify_stack_protector_test() {
// 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;
- p = reinterpret_cast<volatile char*>(&p + 1);
- *p = '\0';
+ // We can't make a constant change, since the existing byte might already have
+ // had that value.
+ volatile char* p = reinterpret_cast<volatile char*>(&p + 1);
+ *p = ~*p;
}