Question: The lines in the following code are identified by the number to the left. This code has a buffer overflow vulnerability. Which lines of code

The lines in the following code are identified by the number to the left. This code has a buffer overflow vulnerability. Which lines of code can be changed to correct the vulnerability?
Line #
int main(int argc, char *argv[]){
1)
int valid = FALSE;
2)
char str1[8];
3)
char str2[8];
4)
next_tag(str1);
5)
gets(str2);
6)
if (strncmp(str1, str2,8)==0)
7)
valid = TRUE;
8)
printf("buffer1: str1(%s), str2(%s), valid(%d)
", str1, str2, valid);
}
Question 22 options:
lines 5 and 8
lines 2 and 3
lines 6 and 8
lines 5 and 6

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!