I found out that for prevent to buffer overflow I can use that instruction (gcc -fstack-protector -S XXX.c
).
For example, I have a file that name is test.c
and that file has a buffer overflow, (ex. there is char buf[10];
but I want to strcpy(buf,"HelloUnixAndLinux")
)
In that case
$gcc -fstack-protector -S test.c
$cat test.s
will check the buffer and let me know as print out something long display including stack_chk_fail
.
I want to know about those instructions but there is nothing explain about it. (I just found out that way on Internet without any effect)
I want to know that
Those option always prevent buffer overflow automatically? (ex. if some function can lead to buffer overflow, automatically not process
strcpy
etc)Is there any way to check is my GCC provide a tool for checking stack smashing? Mine is GCC 4.4.6 Red Hat 4.4.6-4.
Is there any way to display warning about buffer overflow after
./a.out
?