栈溢出原理
介绍
基本示例
#include <stdio.h>
#include <string.h>
#define PASSWORD "666666"
int verify_password(char *password)
{
int authenticated;
char buffer[8];
authenticated = strcmp(password,PASSWORD);
strcpy(buffer,password);
return authenticated;
}
void main()
{
int valid_flag =0;
char password[128];
while(1)
{
printf("please input password: ");
scanf("%s",password);
valid_flag = verify_password(password);
if (valid_flag !=0)
{
printf("incorrect password!\n");
}
else
{
printf("Congratulation! You have passed the verification!\n");
break;
}
}
}





参考阅读
Last updated