Research and discuss the principle of exploits based on buffer-overflow attacks.

How can buffer-overflow attacks be avoided?