static int checkPassword(char* user_pw) {
char dummy[128];
int accept = 0;
char pw[8];
char len;
char* correct_pw = "xf35+";
memset(pw, 0, sizeof(pw));
memset(dummy, 0, sizeof(dummy));
len = strlen(user_pw);
if (len < 8) {
strcpy(pw, user_pw);
}
if (strcmp(pw, correct_pw) == 0) {
accept = 1;
}
return accept;
}
int main(int argc, char* argv[]) {
// Where argv[3] should be password
// ...
if (strlen(argv[3]) > 128) {
fprintf(stderr, "Password is too long!\n");
return 1;
}
if (checkPassword(argv[3]) == 0) {
fprintf(stderr, "Password is incorrect!\n");
return 1;
}
// ...
}
这里的密码是硬编码的,但是有什么办法可以绕过密码检查? 我注意到“ len”被声明为字符,但仍然不知道如何解决这个问题