Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider (sch jbop) (X_X)@==(Q_Q)@

...

Code Block
bgColor#ffcccc
/*  Program running with elevated privileges where argv[1] and argv[2] are supplied by the user */

char x[100];
FILE *fp = fopen(argv[1],"w");     

strncpy(x, argv[2], 100);
x[100] = '\0';

fwrite(x, sizeof(x[0]), sizeof(x)/sizeof(x[0]), fp);   /*  Write operation to an unintended file like /etc/passwd gets executed  */

...