Buffer Overflows

Public preview

Want everyone on your software team to learn this? Free 14-day trial.

Train my team
oops.c
c
void askForUsername()
{
  // Buffer can only hold 8 characters!
  char buffer[8];

  printf("Enter your username:\n");
  scanf("%s", buffer);
  printf("You entered: %s\n", buffer);
}

int main()
{
  while(1) askForUsername();

  return 0;
}
Running: "oops.c"
Enter your username: