8
Answers

Some help with a small piece of code

Kev Li

Kev Li

16y
4.6k
1
Hi everyone,

I am trying to understand a question set to me by my lecturer. The textbook given to us doesn't provide any information on it as well.

Below is an example of a code that the lecturer wants us to edit so that it is no longer vulnerable to buffer overflow attacks.

            int copy_buf(char *to, int pos, char *from, int len)

     {

          int i;

          for (i=0; i<len; i++) {

              to[pos] = from[i];

              pos++;

          }

     return pos;

     }

does anyone have any ideas how to do this? or able to solve this?
- Thanks
Answers (8)