Skip to content

Instantly share code, notes, and snippets.

@diondokter
Created February 28, 2026 09:05
Show Gist options
  • Select an option

  • Save diondokter/c41edb945cccbf76890cde3d282419d8 to your computer and use it in GitHub Desktop.

Select an option

Save diondokter/c41edb945cccbf76890cde3d282419d8 to your computer and use it in GitHub Desktop.
Fil fail
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
/* if you compile this source to ./a.out,
* what is the result of "echo filfail | ./a.out" ? */
struct {
char name[7];
bool is_restricted;
} user;
int main(void) {
user.is_restricted = true;
printf("Name: ");
fflush(stdout);
gets(user.name);
if(strcmp(user.name, "admin") == 0) {
user.is_restricted = false;
}
if(user.is_restricted) {
puts("access is denied");
return 1;
} else {
puts("welcome administrator");
return 0;
}
}
$ echo FILFAIL | ./a.out
welcome administrator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment