What is the difference between STATUS_STACK_BUFFER_OVERRUN and STATUS_STACK_OVERFLOW?

筅森魡賤 提交于 2019-12-21 12:12:32

问题


I just found out that there is a STATUS_STACK_BUFFER_OVERRUN and a STATUS_STACK_OVERFLOW. What's the difference between those 2? I just found Stack overflow (stack exhaustion) not the same as stack buffer overflow but either it doesn't explain it or I don't understand it. Can you help me out?

Regards Tobias


回答1:


Consider the following stack which grows downward in memory:

+----------------+
| some data      |   |
+----------------+   | growth of stack
| 20-byte string |   V
+----------------+
 limit of stack

A buffer overrun occurs when you write 30 bytes to your 20-byte string. This corrupts entries further up the stack ('some data').

A stack overflow is when you try to push something else on to the stack when it's already full (where it says 'limit of stack'). Stacks are typically limited in their maximum size.




回答2:


Stackoverflow appears when there is no more space in memory to allocate your data, and buffer overrun a.k.a. buffer overflow is called when program overruns buffer boundary and writes/overwrites data in unexpected part of memory (takes more memory than expected).

Easily, you can understand this just by reading description of tags stackoverflow and buffer overflow.



来源:https://stackoverflow.com/questions/12837134/what-is-the-difference-between-status-stack-buffer-overrun-and-status-stack-over

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!