From 47107014052cf2345f4d22066e236582f4bbc0a9 Mon Sep 17 00:00:00 2001 From: Lucas Jenss Date: Fri, 20 Oct 2017 11:43:29 +0200 Subject: [PATCH] tests/ssp: Fix on macOS while compiling w/ clang On macOS using Apple LLVM version 9.0.0 this test would not compile due to clang detecting the buffer overflow. Since this test is all about having a buffer overflow, I tricked clang into not detecting this anymore. This loosely relates to #6473. --- tests/ssp/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ssp/main.c b/tests/ssp/main.c index ec5c1bc1fd..c7e7ca679c 100644 --- a/tests/ssp/main.c +++ b/tests/ssp/main.c @@ -28,9 +28,13 @@ void test_func(void) { char buf[16]; + /* clang will detect the buffer overflow + * and throw an error if we use `buf` directly */ + void *buffer_to_confuse_compiler = buf; + /* cppcheck-suppress bufferAccessOutOfBounds * (reason: deliberately overflowing stack) */ - memset(buf, 0, 32); + memset(buffer_to_confuse_compiler, 0, 32); } int main(void)