Browse Source

tests: add SSP (stack smashing protector) test application

master
Kaspar Schleiser 6 years ago
parent
commit
7b1a1e9d81
  1. 14
      tests/ssp/Makefile
  2. 45
      tests/ssp/main.c

14
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

45
tests/ssp/main.c

@ -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…
Cancel
Save