Undesired values being pushed to the call stack

Hi everyone,

Suppose I've written the following chunk of code (I know it has a format string bug in it, so DON'T remark this):
int main(int argc, char *argv[])
int x = 1;
return 0;

As far as I know when the printf() function is being called the stack looks like this:
[code]old %ebp {2}
return address (printf)
x (1)
old %ebp {1}
return address (main)

This layout basically means that if I run the program with "%x" as its invocation argument (and yes, I know it's a format string bug) I should get the value of x, which is 1.

However, in reality what I get is this:
[code]$ ./program "%x" 8049658[/code]

Second execution attempt:
[code]$ ./format "%x %x %x %x" 8049658 ffffd4f8 8048469 1[/code]

My question is what are those strange values being pushed onto the stack? Is there any way to turn down this nasty feature?

Thanks in advance.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!