Skip to content

Instantly share code, notes, and snippets.

@umair-khokhar
Created April 8, 2019 02:15
Show Gist options
  • Select an option

  • Save umair-khokhar/5508271c22be33b055d3867a2b731f93 to your computer and use it in GitHub Desktop.

Select an option

Save umair-khokhar/5508271c22be33b055d3867a2b731f93 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_WORD_LENGTH 5
int main(int argc, char *argv[])
{
char password[5];
int authenticate = 0;
printf("Enter a word (<%d chars): ", MAX_WORD_LENGTH);
fflush(stdout);
scanf("%s", password); /* DANGER: vulnerable to buffer overflow*/
if(strcmp(password, "correct") == 0)
authenticate = 1;
if(authenticate)
printf("You are authorized");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment