Prevent crash in passwordgood when supplied password is one character long

This commit is contained in:
Henrik Olsson 2014-07-06 13:36:07 +02:00
parent d704c69b90
commit 956ec310e8
1 changed files with 5 additions and 1 deletions

View File

@ -2051,9 +2051,13 @@ newuser ()
int
passwordgood (char *cpw)
{
char *crypted;
assert (me != NULL);
if (!strncmp (crypt (cpw, cpw), me->password, DGL_PASSWDLEN))
crypted = crypt (cpw, cpw);
if (crypted == NULL)
return 0;
if (!strncmp (crypted, me->password, DGL_PASSWDLEN))
return 1;
if (!strncmp (cpw, me->password, DGL_PASSWDLEN))
return 1;