]> skyeroc.xyz Git - dgamelaunch/commitdiff
Prevent crash in passwordgood when supplied password is one character long
authorHenrik Olsson <henrik@fixme.se>
Sun, 6 Jul 2014 11:36:07 +0000 (13:36 +0200)
committerHenrik Olsson <henrik@fixme.se>
Sun, 6 Jul 2014 11:36:07 +0000 (13:36 +0200)
dgamelaunch.c

index fbf6ef551e83940d31bce941e09530c9ad8ccf1f..d6f3ee63040952f65c3b2499604fbce03535066a 100644 (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;