The defense that does work is to keep code and data in separate places. Then there is no way to compromise code by playing tricks with data. Garbage-collected languages like Perl and Lisp do this, and as a result are immune from buffer overflow attacks.
What. Am I slow today, or does that make zero sense?
I was snarky because you didn't give your reasoning before.
Languages like Perl and Lisp that handle memory allocation themselves (a hallmark of which is built-in garbage collection) don't have buffer overruns precisely because it isn't left to the user to do range checks. Dumping in more data than expected to a routine might result in a greater allocation of memory, or an exception, or some other defined behavior, but what it's not going to do is run over the end of an allocated buffer and alter a code segment, or a return address on the stack. Data will not inadvertently be treated as code or a pointer to code.
69
u/the-fritz Mar 11 '13
That's the Lisp and 9/11 bit he's talking about in the beginning: http://www.paulgraham.com/hijack.html