Using Format Strings Consider an Example format3.c:a function which contains only a printf()function: 1/*---printf()----*/ 2#include <stdio.h> 3#include <string.h> 4void function(int n) 5{ 6 printf("Number of patameters the stack %d\n",n); 7} 8int main() 9{ 10 function(2); 11 return 0; 12} 16
Using Format Strings • Consider an Example format3.c : a function which contains only a printf() function: 16 1 2 3 4 5 6 7 8 9 10 11 12 /*------printf()-------*/ #include <stdio.h> #include <string.h> void function(int n) { printf("Number of patameters the stack : %d\n",n); } int main() { function(2); return 0; }
Assembly code Disassembling the function on dgb: oyjb@ubuntu:~/Desktop/Testcode (gdb)disas function Dump of assembler code for function function: 0x0804841b<+0>: push %ebp 0x0804841c<+1>: mov %esp,%ebp 0x0804841e<+3>: sub $0x8,%esp 0x08048421<+6>: sub $0x8,%esp 0x08048424<+9>: pushl 0x8(%ebp) 0x08048427<+12>: push S0x80484f0 0x0804842c<+17>: call 0x80482f0 <printf@plt> 0×08048431<+22>: add $0x10,%esp 0x08048434<+25>: leave 0x08048435<+26>: ret End of assembler dump. (gdb)x/s 0x80484fo 0x80484f0: "Number of patameters the stack %d\n" (gdb)】
Assembly code • Disassembling the function on dgb: 17