Question: 9 . Rewrite the two functions shown below so they are no longer vulnerable to a buffer overflow attack. Don t use any safe libraries

9. Rewrite the two functions shown below so they are no longer vulnerable to a buffer overflow attack. Dont use any safe libraries in your solution.
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 ;
}
short read_chunk ( FILE fil , char * to )
{
short len ;
fread (& len ,2,1, fil );
fread (to ,1, len , fil );
return len ;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!