summaryrefslogtreecommitdiff
path: root/tests/stack_protector_test_helper.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-15 10:06:09 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-15 10:06:09 +0000
commitd1d65eae22ae4dbb2c0bfb8427d8223a8e9fc6a7 (patch)
treed9006ac00ea95c86be208575ee29d4ea6978abc1 /tests/stack_protector_test_helper.cpp
parent1003265aef8974ae1af0390d88c5cdc9e1dece69 (diff)
parenta45a05c360e8fb2fa264249d6d958de004fb7fe5 (diff)
Snap for 10323517 from a45a05c360e8fb2fa264249d6d958de004fb7fe5 to t-keystone-qcom-release
Change-Id: Ibce09e9d0ca566a71589c9dbe970abc956afeaef
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;
}