用來保護棧不被毀壞。 void function(char *str) { char buffer[16]; strcpy(buffer,str); } void main() { char large_string[256]; int i; for( i = 0; i < 255; i++) large_string[i] = 'A'; function(large_string); } $ gcc -fstack-protector test.c $ ./a.out *** stack smashing detected ***: terminated ====== 相關資料 ====== * [[http://insecure.org/stf/smashstack.html|Smashing The Stack For Fun And Profit]] ====== 外部連結 ====== * [[http://wiki.osdev.org/GCC_Stack_Smashing_Protector|GCC Stack Smashing Protector]] * [[wp>Stack buffer overflow]] * [[wp>Buffer overflow protection]] * [[http://llvm.org/docs/doxygen/html/StackProtector_8cpp_source.html|StackProtector.cpp]]