Aliensbrain
  • Home
  • Topics
  • Quizzes
  • Notebooks
  • Community
  • Sign in
  • security Online Quiz - 10
  • What can go wrong in following code? ```c #include <stdi...

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 buffer1[5];
    strcpy(buffer1, argv[1]);
    char buffer2[5];
    strcpy(buffer1, argv[1]);
    char x;
    FILE *file[2];
    file[0] = fopen(buffer1,"r+");
    file[1] = fopen(buffer2,"w+");
    for(x = 0; x &lt; 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 &lt; 2; x++)         
        fclose(file[x]);
    return 0;
}
technology security
  1. XSS

  2. Arc Injection

  3. Buffer Overflow

  4. both 2 and 3


Show answer
Correct Option: D

Find more quizzes:

© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy