堆栈溢出和缓冲区溢出有什么区别? [英] What is the difference between a stack overflow and buffer overflow?

查看:445
本文介绍了堆栈溢出和缓冲区溢出有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编程中的堆栈溢出和缓冲区溢出有何不同?

What is different between stack overflow and buffer overflow in Programming ?

推荐答案

堆栈溢出专门是指执行堆栈超​​出为其保留的内存的情况.例如,如果您调用的函数在不终止的情况下递归地调用自身,则会导致堆栈溢出,因为每个函数调用都会创建一个新的堆栈帧,并且该堆栈最终将消耗比为其保留的内存更多的内存.

Stack overflow refers specifically to the case when the execution stack grows beyond the memory that is reserved for it. For example, if you call a function which recursively calls itself without termination, you will cause a stack overflow as each function call creates a new stack frame and the stack will eventually consume more memory than is reserved for it.

缓冲区溢出是指程序在超出为任何缓冲区分配的内存末尾写入的任何情况(包括在堆上,而不仅仅是在堆栈上).例如,如果您从堆分配的数组的末尾写入数据,则会导致缓冲区溢出.

Buffer overflow refers to any case in which a program writes beyond the end of the memory allocated for any buffer (including on the heap, not just on the stack). For example, if you write past the end of an array allocated from the heap, you've caused a buffer overflow.

这篇关于堆栈溢出和缓冲区溢出有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆