堆栈方向和缓冲区溢出
在向下增长的堆栈中,堆栈变量向上写入的基本原理是什么?例如,如果我有 char buf[200],则位于内存地址 0x400。当我写入这个数组时,我将从 0x400 写入到 0x600,这是朝向之前的堆栈帧的。这使得程序容易受到缓冲区溢出的影响,缓冲区溢出可以通过覆盖返回指针等来控制程序。那么为什么不直接将数组从 0x600 写入到 0x400 呢?
In a downward growing stack, what's the rationale for stack variables to be written in an upward direction? For example, if I have char buf[200], say at memory address 0x400. When I write to this array, I will write from 0x400 to 0x600, which is toward previous stack frames. This makes the program vulnerable to buffer overflows that can take control over the program by overwriting return pointers, etc. So why not just write the array from 0x600 to 0x400?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系;当您尝试写入超过 200 个字节时,您仍在尝试写入不属于数组的地址(越界),因此缓冲区溢出。
It doesn't matter; when you try to write beyond 200 bytes, you are still trying to write to an address that does not belong to the array (out of bounds), hence buffer overflow.