Buffer Overflow (vs) Buffer OverRun (vs) Stack Overflow

Possible duplicate:
What is the difference between stack overflow and buffer overflow?

What is the difference between buffer overflow and buffer overflow?

What is the difference between buffer overflow and stack overflow?

Please provide sample code. I looked at the conditions on Wikipedia, but I can not match programming in C or C ++ or Java.

+4
source share
4 answers

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).

+24
source

Bufferoverflow / Bufferoverrun:

void k() { BYTE buf[5]; for( int i = 0; i < 10; ++i ) buf[i] = 0xcd; } 

Stackoverflow:

 void f() { int k = 0; f(); } 
+16
source

You may have a difference between buffer overflows and buffer overflows in C / C ++:

  • We could detect overflow when you index / point beyond the original buffer size (for example, read the 6th element from a 3 element array)
  • We could detect an overflow when you have several adjacent buffers one after another and you index into the second (for example, read the 6th element of the first 3-element array, but you will get the third element of the second 3-element array).

A stack overflow is a buffer overflow when you fill up the entire memory buffer of your stack.

+1
source

What is the difference between buffer overflow and buffer overflow? I would say that Buffer over flow is when you try to write outside the end of the buffer, but you have a check that prevents it. buffer over run is when you actually write outside the end of the buffer. The first does not work fast, the second is more difficult to detect.

You cannot overload a buffer in java, since it always has bounds checking and thus throws a BufferOverflowException.

What is the difference between buffer overflow and stack overflow?

They have nothing to do with each other.

0
source

All Articles