I have written the following C program to see the working of buffer overflows. I have saved this program file with name bo.c
#include<stdio.h>
#include<string.h>
int authentication(char *key)
{
int auth=0;
char pass[10];
strcpy(pass, key);
if(strcmp(pass, "hello")==0)
auth=1;
else
auth=0;
return auth;
}
int main(int argc, char *argv[])
{
if(authentication(argv[1]))
{
printf("----------------------------------\nACCESS GRANTED\n---------------------------------");
}
else
{
printf("Access Denied! Wrong password!");
}
return 0;
}
But I am not able to see the effect of buffer overflow because the stack is protected. But when I am compiling it with the -fno-stack-protector flag, it is showing that it is an unrecognized option.
What is the problem here? Am I doing something wrong in the usage of the gcc command?