作者:没有结果的爱请你收好 | 来源:互联网 | 2023-09-12 01:53
SoIvebeenlearningaboutBufferOverflowaswellastheProcedureforsavingmemoryontothestac
So I've been learning about Buffer Overflow as well as the Procedure for saving memory onto the stack and ive been bothered/ I dont understand certain conventions. When saving local variables/ arrays why is that we allocate memory from the stack pointer to the base pointer
所以我一直在学习缓冲区溢出以及将内存保存到堆栈的过程,并且我一直困扰/我不理解某些约定。保存局部变量/数组时,为什么我们将堆栈指针中的内存分配给基指针
(array[0] would be closer to the top of the stack and array[1] to array [n-1] would be closer to the base pointer of your frame)
(array [0]将更靠近堆栈顶部,array [1]到array [n-1]将更接近于帧的基本指针)
Why not the other way around? if array[n-1] was allocated towards the stack pointer there would be no threat to the saved registers/ return addresses in the previous frame.
为什么不相反呢?如果将array [n-1]分配给堆栈指针,则不会对前一帧中保存的寄存器/返回地址构成威胁。
I've read the wiki article and the stacks that grow up section, but they assume the return address is there before the buffer is allocated, which would mean the buffer overwrites the return. But shouldnt it be the other way around? Shouldnt the return address be written in the stack only after the local variables are declared?
我已经阅读了wiki文章和成长部分的堆栈,但他们假设在分配缓冲区之前返回地址,这意味着缓冲区会覆盖返回。但不应该是相反的方式吗?只有在声明了局部变量之后,才能将返回地址写入堆栈中吗?
2 个解决方案