American Literature
Format string vulnerability.
Problem
Solution
int length;
char essay[50];
setbuf(stdout, NULL);
setbuf(stdin, NULL);
setbuf(stderr, NULL);
...
FILE *fp = fopen("flag.txt", "r");
char example_essay[100];
...
fgets(example_essay, sizeof(example_essay), fp);
...
fgets(essay, sizeof(essay), stdin);
essay[strcspn(essay, "\n")] = 0;
length = strlen(essay);
...
printf(essay);
...

Last updated