diff options
Diffstat (limited to 'examples/buffer-overflow/buffer-overflow.c')
-rw-r--r-- | examples/buffer-overflow/buffer-overflow.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/buffer-overflow/buffer-overflow.c b/examples/buffer-overflow/buffer-overflow.c new file mode 100644 index 0000000..96f0ee8 --- /dev/null +++ b/examples/buffer-overflow/buffer-overflow.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <string.h> + +int main(void) +{ + char buf[16]; + int ok = 0; + + printf("Type admin password: \n"); + gets(buf); + + if (strcmp(buf, "pass123")) printf("\nWrong password!\n"); + else ok = 1; + + if (ok) printf("\nLogged in as admin.\n"); + + return 0; +} |