What is the maximum value sprintf
can put into stack for this bufferoverflow case as i noticed for normal printf(string)
will allow more values
When passing a value > ("%1500d"
) error will happen , passing a value > than previous value ("%50000d"
)
another error happen
So what is the exact relation between it and stack?
When passing more empty argv
argument when running the file it allow more padding values
Why is that?
compile & running
gcc code.c -o code
./code "%1500d"
void vuln(char *string)
{
char buffer[64];
sprintf(buffer, string);
}
int main(int argc, char **argv)
{
vuln(argv[1]);
}
gdb
"%1500d"
error
=> 0x7ffff7a9c57b <__mempcpy_sse2+331>: rep movs QWORD PTR es:[rdi],QWORD PTR ds:[rsi]
Stopped reason: SIGSEGV
__mempcpy_sse2 () at ../sysdeps/x86_64/memcpy.S:272
272 ../sysdeps/x86_64/memcpy.S: No such file or directory.
"%50000d"
error
=> 0x7ffff7a8868b <__GI__IO_default_xsputn+75>: mov BYTE PTR [rdi+rax*1],dl
Stopped reason: SIGSEGV
0x00007ffff7a8868b in __GI__IO_default_xsputn (f=0x7fffffffe1a0,
data=<optimized out>, n=0x10) at genops.c:450
450 genops.c: No such file or directory