Think of the buffer as a simple array. Buffer overflow is when you try to put more elements in an array than what the array can contain. In other words, it comes from the record .
A buffer overflow is when you iterate over a buffer and keep reading past the end of the array. In other words, it comes from reading .
Stack overflow is very different. Most modern software environments are stack based, where they use the stack data structure to control the flow of programs. Each time you call a function, a new element is pushed onto the program call stack. When the function returns, the item is popped from the stack. When the stack is empty, the program stops. The fact is that this stack has a fixed size, and therefore you can call too many functions at the same time. You currently have a stack overflow. The most common way to do this is with a function that calls itself (recursion).
source share