Multiple choice technology security

Which statement creates a buffer over flow? #include #include #include int main (int argc, char argv[]) { int i=0,j=1; char ipstring[80]; for (;i<=3;i++){ cout<<"\n entering a new character\n"; j=getchar(); /*1/ cout<<”enter a string”; gets(ipstring); /2/ cout<

  1. j=getchar();

  2. gets(ipstring);

  3. Both

  4. None

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

gets() has no buffer length check and writes past ipstring's 80-byte boundary. This is a classic buffer overflow. getchar() reads one character into j, which is safe. Option C is wrong because getchar() is not unsafe.