mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
tests: add SSP (stack smashing protector) test application
This commit is contained in:
parent
7a0fcc30c8
commit
7b1a1e9d81
14
tests/ssp/Makefile
Normal file
14
tests/ssp/Makefile
Normal file
@ -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
|
45
tests/ssp/main.c
Normal file
45
tests/ssp/main.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* 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 <kaspar@schleiser.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user