#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv) {
int modified;
char buffer[64];
modified = 0;
gets(buffer);
if(modified != 0)
printf("Changed!");
else
printf("Not changed!");
}
I'm trying to play around with a buffer overflow.
When the program counter gets to if(modified != 0), the base pointer is 0x00007fffffffdfe0.
Right below the base pointer, I see 4 bytes that contains integer 0 which makes sense.
However, the buffer is not right below the int modified.
It looks like 4 bytes of 0s then 0x00007fff are in the stack then 64 bytes of As that I entered follows after.
Why doesn't char buffer[64] come right after the int modified? why is there a "gap"?
I compiled it with gcc -g -fno-stack-protector test1.c -o test1
Thanks