1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me with this code

Discussion in 'C' started by stranger_on_way, Sep 8, 2010.

  1. stranger_on_way

    stranger_on_way New Member

    Joined:
    Sep 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    void function(int a, int b, int c) {
       char buffer1[5];
       char buffer2[10];
       int *ret;
    
       ret = buffer1 + 12;
       (*ret) += 8;
    }
    
    void main() {
      int x;
    
      x = 0;
      function(1,2,3);
      x = 1;
      printf("%d\n",x);
    }
    I found this code on smashing the stack tutorial and the code given here is expected to jump"x=1;" assignment statement but the code is not working as desired... anyone please help in explaining and correcting this buffer overflow sample code.
     

Share This Page