From 7b1a1e9d8183e50780a62e4ca4a0c5f3e8ea2231 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Sun, 4 Dec 2016 20:55:33 +0100 Subject: [PATCH] tests: add SSP (stack smashing protector) test application --- tests/ssp/Makefile | 14 ++++++++++++++ tests/ssp/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/ssp/Makefile create mode 100644 tests/ssp/main.c diff --git a/tests/ssp/Makefile b/tests/ssp/Makefile new file mode 100644 index 000000000..3ce3b2407 --- /dev/null +++ b/tests/ssp/Makefile @@ -0,0 +1,14 @@ +APPLICATION = ssp +include ../Makefile.tests_common + +# avr8, msp430 and mips don't support ssp (yet) +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove \ + chronos msb-430 msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1 \ + pic32-clicker pic32-wifire + +USEMODULE += ssp + +# set DEVELHELP so the board halts after crash +CFLAGS += -DDEVELHELP + +include $(RIOTBASE)/Makefile.include diff --git a/tests/ssp/main.c b/tests/ssp/main.c new file mode 100644 index 000000000..ec5c1bc1f --- /dev/null +++ b/tests/ssp/main.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2016 Kaspar Schleiser + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief ssp test application + * + * This test should crash badly when *not* using the ssp module, and panic if + * using it. + * + * @author Kaspar Schleiser + * + * @} + */ + +#include +#include + +void test_func(void) +{ + char buf[16]; + + /* cppcheck-suppress bufferAccessOutOfBounds + * (reason: deliberately overflowing stack) */ + memset(buf, 0, 32); +} + +int main(void) +{ + puts("calling stack corruption function"); + + test_func(); + + puts("back to main"); + + return 0; +}