|
Здесь можно подчеркнуть различие между переполнением буфера и переполнением стека - в первом случае ошибка происходит при обращении к неверной области памяти, и если защита на этом этапе отсутствует, в этот момент не проявляет себя - при удачном стечении обстоятельств программа может отработать нормально. Если только память, к которой шло обращение, была защищена, происходит ошибка сегментации.
|
|
An error known as a stack overflow will occur. Since a stack is used to arrange calls of user subroutines (and most programs written in contemporary programming languages - including object-oriented ones - actively employ functions one way or another), the program won't be able to call any function after the error occurs. When that happens, the operating system takes control back, clears the stack and terminates the program. Here lies the difference between the buffer overflow and the stack overflow. The former occurs when the program attempts to access a memory area outside the buffer's boundary and remains unnoticed if there is no protection against that; the program goes on to run correctly if lucky enough. It's only when there is memory protection that a segmentation fault occurs. But when a stack overflow occurs, the program inevitably crashes.
|