I am trying to do an example from the Smashing the Stack for Fun and Profit in C, but am kind of stuck at a point,
following is the code (I have a 64-bit machine with Ubuntu 64-bit):
x = 0;
x = 1;
printf("x is : %d\n", x);
void func(int a, int b, int c)
ret = buffer + 17;
(*ret) += 7;
The above code works fine and on returning the
x=1 line is not executed, but I can’t understand the logic behind
ret = buffer + 17;, shouldn’t it be
ret = buffer + 16; i.e, 8bytes for buffer and 8 for the saved base pointer on stack.
Secondly, my understanding is that
char buffer is taking 8 bytes (owing to 64-bit arch)
and if I increase this buffer to say
buffer, still the same code should work fine, BUT this is not happening and it starts giving seg fault.