Search code examples
linuxgccstackcorrupt

Linux gcc: How to write a quick function to corrupt the stack?


I am learning about stack frames, and I wish to know if we can write a function which shows how stack is corrupted? I wish to see an example in c/c++ not assembly language.

If we don't do array index overflow or vicious array/address indexed visit(read/write), is there a possibility that stack gets corrupted? Any quick samples?

Thanks.


Solution

  • you may be interested in the excellent article "Smashing the stack for fun and profit" (http://insecure.org/stf/smashstack.html) which explains how to overwrite stack pointer and execute additional code. This is a classic.

    Good luck!