Did I also mention that there's so many security vulnerabilities in that that... ah whatever, not like anyone would be stupid enough to use something like that for actual "security"
Name:
Anonymous2010-04-25 18:59
>>1
To compare strings, use strcmp(s1, s2). This function will return zero if the two strings are identical.
Also, using gets() and fixed-size string buffers is a greatway of making ENTERPRISE-QUALITY VULNERABILITIES.
Name:
Anonymous2010-04-25 18:59
I know this fails for security, but it is what my teacher wants.
Even if fix all the vulnerabilities in your example, it's still a terribad idea.
1) You seem to be building this on Windows, so you're going to give this exe to someone to run right? He can just use a disassembler, or in this case (since there's no encryption), he could just run a "strings" on it or whatever.
2) If this was meant as some sort of remote-auth. I've once encountered such sillyness in a *nix environment where the permissions were +x only (no r/w). a bit of minimal gdb magic and the password presented itself.
The only way this can work is if it's fully remote and the user has no way on accessing the local file.
>>14
Walk the array, comparing every username with the one provided. If they are equal, compare the password associated with that username with the provided password. If they are equal, yay, otherwise, noes. Make the last array entry { NULL, NULL } so you can stop on the last username by checking whether it is null.