开发者

Stack direction and buffer overflow

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 overf开发者_运维技巧lows that can take control over the program by overwriting return pointers, etc. So why not just write the array from 0x600 to 0x400?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜