Well assuming we have some trivial program:
Code:
void foo(char* name)
{
char buffer[10];
sprintf(buffer, "Dear %s ", name);
printf("this is the end of foo(). Goodbye. \n");
}
void main(int argc, char **argv)
{
if ( argc > 1 )
foo(argv[1]);
}
I want to make it so that it outputs some alternative ending that I insert into the program other than "this is the end of foo(). Goodbye. " so rather than it printing:
/.prog Julie
Dear Julie this is the end of foo(). Goodbye.
I wanted to overwrite it so that it would do something to effect of:
./prog Julie, you stink.
Dear Julie, you stink.
and it would completely bypass the last printf statement in foo().
I'm still relatively new to using GDB and other than run, step, b, and disas I'm not too sure what other functions could show me a sort 'snapshot' of the register contents and what is being overwritten.