mirror of https://github.com/flysand7/ciabatta.git
Support for -fstack-protector
This commit is contained in:
parent
e5f2711091
commit
b426c0f2ee
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
u64 __security_cookie;
|
||||||
|
|
||||||
|
void __security_init_cookie() {
|
||||||
|
// They say it's a random number so I generated
|
||||||
|
// one using numbergenerator.org
|
||||||
|
__security_cookie = 0xb26e04cc62ba48a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __security_check_cookie(u64 retrieved) {
|
||||||
|
if(__security_cookie != retrieved) {
|
||||||
|
printf("Bro you've got a buffer overrun\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ _Noreturn void mainCRTStartup() {
|
||||||
_setup_heap();
|
_setup_heap();
|
||||||
_setup_timer();
|
_setup_timer();
|
||||||
_setup_io();
|
_setup_io();
|
||||||
|
__security_init_cookie();
|
||||||
|
|
||||||
srand(0);
|
srand(0);
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
|
@ -28,6 +29,7 @@ _Noreturn void WinMainCRTStartup() {
|
||||||
_setup_heap();
|
_setup_heap();
|
||||||
_setup_timer();
|
_setup_timer();
|
||||||
_setup_io();
|
_setup_io();
|
||||||
|
__security_init_cookie();
|
||||||
|
|
||||||
srand(0);
|
srand(0);
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
|
|
|
@ -12,3 +12,4 @@ void _setup_eh();
|
||||||
void _setup_heap();
|
void _setup_heap();
|
||||||
void _setup_io();
|
void _setup_io();
|
||||||
void _close_io();
|
void _close_io();
|
||||||
|
void __security_init_cookie();
|
|
@ -66,6 +66,7 @@
|
||||||
// Windows stuff
|
// Windows stuff
|
||||||
#if defined(CIABATTA_WIN)
|
#if defined(CIABATTA_WIN)
|
||||||
#include "_win/win.h"
|
#include "_win/win.h"
|
||||||
|
#include "_win/cookie.c"
|
||||||
#include "_win/assert.c"
|
#include "_win/assert.c"
|
||||||
#include "_win/cmdline.c"
|
#include "_win/cmdline.c"
|
||||||
#include "_win/entry.c"
|
#include "_win/entry.c"
|
||||||
|
|
2
test.cmd
2
test.cmd
|
@ -1,2 +1,2 @@
|
||||||
|
|
||||||
clang -std=c11 test\%1 utf8.obj -Iinc -g -lciabatta.lib -nostdlib
|
clang -std=c11 test\%1 utf8.obj -Iinc -g -lciabatta.lib -nostdlib -fstack-protector
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
int main() {
|
||||||
|
uint8_t *sp = _alloca(512);
|
||||||
|
for(int i = 0; i != 550; ++i) {
|
||||||
|
sp[i] = 0;
|
||||||
|
}
|
||||||
|
printf("%p\n", sp);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("Hello, World!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue