Multiple choice technology security

What can go wrong in following code?

#include   
int main(int argc, char *argv[]) {

if(argc != 3) {
        printf("usage: %s [source] [dest]\n", argv[0]);
        exit(1);

    }

    char x;
    FILE *file[2];
    file[0] = fopen(argv[1],"r+");
    file[1] = fopen(argv[2],"w+");
    for(x = 0; x < 2; x++) { 
        if(file[x] == NULL) {
            printf("error opening file.\n");
            exit(1);
        }
    }

    do {
        x = fgetc(file[0]);
        fputc(x,file[1]);
    } while(x != EOF);

     for(x = 0; x < 2; x++)
        fclose(file[x]);
     return 0; 
}

  1. SQL Injection

  2. Arc Injection

  3. Buffer Overflow

  4. both 2 and 3

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

The code exhibits a classic buffer overflow vulnerability through its file handling approach. The variable 'x' is declared as char instead of int, which cannot properly represent EOF (-1). This causes an infinite loop because fgetc() returns EOF as an int, but storing it in a char truncates the value, preventing proper loop termination. Additionally, the lack of input validation on file sizes means the code blindly copies content without bounds checking. SQL Injection (A) and Arc Injection (B) are unrelated to this memory corruption issue.