misc/libphysfs/platform_macosx.c
changeset 9183 4cd7c7aafea7
parent 8928 10a79d89ca31
child 10017 de822cd3df3a
--- a/misc/libphysfs/platform_macosx.c	Tue Jun 11 01:40:55 2013 +0300
+++ b/misc/libphysfs/platform_macosx.c	Tue Jun 11 00:01:32 2013 +0200
@@ -44,6 +44,31 @@
     fflush(stderr);
     abort();
 }
+
+
+/* apparently libssp is missing from 10.4 SDK
+   code from http://wiki.osdev.org/GCC_Stack_Smashing_Protector */
+void * __stack_chk_guard = NULL;
+
+void __stack_chk_guard_setup()
+{
+    unsigned char * p;
+    p = (unsigned char *) &__stack_chk_guard;
+
+    /* If you have the ability to generate random numbers in your kernel then use them,
+       otherwise for 32-bit code: *p = 0x00000aff; */
+    *p = random();
+}
+
+void __attribute__((noreturn)) __stack_chk_fail()
+{
+    /* put your panic function or similar in here */
+    unsigned char * vid = (unsigned char *)0xB8000;
+    vid[1] = 7;
+    for(;;)
+    vid[0]++;
+}
+
 #endif
 #endif /* __APPLE__ */