hello,
i want to intentionally bypass the statement
x=1;
in the below program.but was unable to do.
i am using gcc and gdb on fedora 8 linux on AMD64 machine.
what i am getting is just segmentation fault.
please put some points how to do that.
thanks.



Code:
/*.................         This program writes bypass a particular statement by process stack  overflow and return to the statement pass x=1 tp printf.... */


// Status: still does not work

#include<stdio.h>
function(int a, int b, int c) 
{
   char buffer1[5];
   char buffer2[10];
   int *ret;

   ret = buffer1 + 12;   // reaching at the ret statement; i.e. return address i.e. saved IP value before coming to function()
   (*ret) += 12;   //overwriting the IP value to past x=1;to know disassemble the main in gdb and count hw much to add hr(12)
}

int main()
 {
  int x;

  x = 0;
  function(1,2,3);
  x = 1;            //this statement is to be skipped by overflow
  printf("%d\n",x);
}

Last edited by shabbir; 1Jun2009 at 22:06.. Reason: Code blocks