http://ftp.x.org/contrib/applications/xscreensaver-2.16.tar.gz
[xscreensaver] / driver / passwd.c
index c8e6f56fe3e755fbbf86f96fd67b775124d2c29a..b0a4b8ad10d8af638aa9a800cd3cf86ed4527c20 100644 (file)
@@ -1,5 +1,5 @@
 /* passwd.c --- verifying typed passwords with the OS.
- * xscreensaver, Copyright (c) 1993-1997 Jamie Zawinski <jwz@netscape.com>
+ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -61,7 +61,7 @@
 #   include <sys/audit.h>
 #   include <pwdadj.h>
 
-#   define PRTYPE   passwd_adjunct *
+#   define PWTYPE   struct passwd_adjunct *
 #   define PWPSLOT  pwa_passwd
 #   define GETPW    getpwanam
 
@@ -70,7 +70,7 @@
 #   include <hpsecurity.h>
 #   include <prot.h>
 
-#   define PRTYPE   struct s_passwd *
+#   define PWTYPE   struct s_passwd *
 #   define PWPSLOT  pw_passwd
 #   define GETPW    getspwnam
 #   define crypt    bigcrypt
@@ -214,16 +214,18 @@ lock_init (int argc, char **argv)
 Bool
 passwd_valid_p (const char *typed_passwd)
 {
+  char *s = 0;  /* note that on some systems, crypt() may return null */
+
   if (encrypted_user_passwd &&
-      !strcmp ((char *) crypt (typed_passwd, encrypted_user_passwd),
-              encrypted_user_passwd))
+      (s = (char *) crypt (typed_passwd, encrypted_user_passwd)) &&
+      !strcmp (s, encrypted_user_passwd))
     return True;
 
   /* do not allow root to have a null password. */
   else if (typed_passwd[0] &&
           encrypted_root_passwd &&
-          !strcmp ((char *) crypt (typed_passwd, encrypted_root_passwd),
-                   encrypted_root_passwd))
+          (s = (char *) crypt (typed_passwd, encrypted_root_passwd)) &&
+          !strcmp (s, encrypted_root_passwd))
     return True;
 
   else