一个简单程序的安全问题
下面是一段程序,用于验证一个PASSWORD是否正确,但是存在一个漏洞,使得攻击者能绕过密码保护逻辑,直接获得对程序的存取权限。哪位大侠帮我看看这个漏洞是什么?十分感谢!
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string>
#include <iostream.h>
#define maxn 12
bool IsPassword0kay(void)
{char Password[maxn];
gets(Password);
if (!strcmp(Password,"goodpass"))
return(true);
else return(false);
}
void main(void)
{
bool PwStatus;
puts("Enter password:");
PwStatus=IsPassword0kay();
if (PwStatus==false)
{
puts("Access denied");
exit(-1);
}
else
puts("Access granted");
}