The following code contains an 8 bytes buffer.
void vuln() { char buffer[8]; gets(buffer); printf("%s",buffer); } int main() { vuln(); return 0; } So, only 8 bytes of stack is expected to be reserved for this buffer. But the disassembly shows 16 bytes being reserved.
(gdb) Dump of assembler code for function vuln: 0x000000000040057d <+0>: push %rbp 0x000000000040057e <+1>: mov %rsp,%rbp 0x0000000000400581 <+4>: sub $0x10,%rsp 0x0000000000400585 <+8>: lea -0x10(%rbp),%rax 0x0000000000400589 <+12>: mov %rax,%rdi 0x000000000040058c <+15>: callq 0x400480 <gets@plt> 0x0000000000400591 <+20>: lea -0x10(%rbp),%rax 0x0000000000400595 <+24>: mov %rax,%rsi 0x0000000000400598 <+27>: mov $0x400644,%edi 0x000000000040059d <+32>: mov $0x0,%eax 0x00000000004005a2 <+37>: callq 0x400450 <printf@plt> 0x00000000004005a7 <+42>: leaveq 0x00000000004005a8 <+43>: retq End of assembler dump. Some actions are to be perform based on the expected size of the buffer on the stack in an automated script. But this crippled the script. May I know the reason why 16 bytes were allocated for the buffer so that I can incorporate it in the script ?