overflow technique in stack

Posted by metashockwave on Stack Overflow See other posts from Stack Overflow or by metashockwave
Published on 2010-05-21T22:24:05Z Indexed on 2010/05/21 22:30 UTC
Read the original article Hit count: 189

Filed under:
|
|
int main(void) {
   problem2();
}

void doit2(void) {
    int overflowme[16];
    //overflowme[37] =0;
}

void problem2(void) {
    int x = 42;
    doit2();
    printf("x is %d\n", x);
    printf("the address of x is 0x%x\n", &x);
}

Would someone help me understand why overflowme[37] =0; from the doit2 function will overwrite the value of x? (please include Program Counter and Frame Pointer of the function doit2 in your explanation) Thank you!

It works every time with Project properties->Configuration properties->C/C++ ->Code Generation->Basic Runtime Checks set to "Default". so it's not an undefined behavior.

© Stack Overflow or respective owner

Related posts about stackoverflow

Related posts about c