I am currently learning C in one of my courses at the university. Now we have a task to solve and I am not sure how to do it.
The task looks like this: "Is it possible to let this program crash with user inputs? If so, explain this case."
The program we have been given is quite simple and looks like this:
#include <stdio.h> // Include to use printf, scanf
int main()
{
// Define buffers to store user name and password
char username[16];
char password[16];
// Read username and password from user input
printf("Enter your name: ");
scanf("%s", username);
printf("Enter your password: ");
scanf("%s", password);
printf("[SHOUTING OUT LOUD] Hello, %s!\n", username);
return 0;
}
I already found out, that you can make the program print out the password, if you use a username longer than 15 chars. But this is obviously not a crash. So I haven't found a way to crash the program, but somehow I am pretty sure, that there is a way to do this. Does somebody has any idea?
Thanks :)