Elffuss BraidHub

kikocis/kleidiai public

chore: Enable overflow protection by default

Set the default buffer policy to check for overflows.

Signed-off-by: Patryk Kaiser <patryk.kaiser@arm.com>

Approved-by: Emil Ohlsson <emil.ohlsson@arm.com>
Changesetcddc29aadae50bf5e69dfd40090b86b0df12b32b0220d4efef72c690c53ba20e
AuthorPatryk Kaiser <patryk.kaiser@arm.com> · 2026-05-21 11:31 UTC
CommitterPatryk Kaiser <patryk.kaiser@arm.com> · 2026-05-21 11:31 UTC
Parents87e5c12d12a8

Browse the files at this changeset

1 file changed

modified test/common/buffer.cpp +9 −2
@@ -1,5 +1,5 @@
11 //
2-// SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2+// SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
33 //
44 // SPDX-License-Identifier: Apache-2.0
55 //
@@ -27,8 +27,15 @@
2727 Buffer::Buffer(const size_t size, const uint8_t init_value = 0) : m_user_buffer_size(size) {
2828 KAI_ASSUME_ALWAYS_MSG(size > 0, "Buffers must be of non-zero size");
2929
30+ // We want to default to overflow protection if supported as it is the most likely failure mode.
31+#if defined(__linux__) || defined(__APPLE__)
32+ const std::string default_protect_mode = "PROTECT_OVERFLOW";
33+#else // defined(__linux__) || defined(__APPLE__)
34+ const std::string default_protect_mode = "NONE";
35+#endif // defined(__linux__) || defined(__APPLE__)
36+
3037 const char* val = getenv(buffer_policy_env_name);
31- const std::string buffer_policy = (val != nullptr) ? std::string(val) : std::string("NONE");
38+ const std::string buffer_policy = (val != nullptr) ? std::string(val) : default_protect_mode;
3239
3340 std::ostringstream oss;
3441