summaryrefslogtreecommitdiff
path: root/src/c/stack_protector.c
blob: 50e4316c9cf688995a113b1a2d85c37da33d5f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdint.h>
#include"../include/stdio.h"
 
#if UINT32_MAX == UINTPTR_MAX
#define STACK_CHK_GUARD 0xe2dee396
#else
#define STACK_CHK_GUARD 0x595e9fbd94fda766
#endif
 
uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
 
__attribute__((noreturn))
void __stack_chk_fail(void)
{
#if __STDC_HOSTED__
	printf("Stack smashing detected\n");
	abort();
#elif __is_myos_kernel
	printf("Stack smashing detected\n");
	panic("Stack smashing detected");
#endif
}