svn commit: r324225 - head/usr.sbin/ppp

Conrad Meyer cem at FreeBSD.org
Mon Oct 2 23:14:31 UTC 2017


Author: cem
Date: Mon Oct  2 23:14:29 2017
New Revision: 324225
URL: https://svnweb.freebsd.org/changeset/base/324225

Log:
  ppp(8): Fix various bugs in NOPAM section of auth_CheckPasswd
  
  * pw is not initialized before use
  * success is returned if crypt(3) errors
  
  These bugs were introduced in r231994, which attempted to adopt DragonflyBSD
  f4a9869feb646aafe72de6e5d61051a023a02676.  The original author of the
  Dragonfly change also noticed these mistakes and filed the PR.
  
  PR:		222620
  Submitted by:	Lubos Boucek <bouceklubos AT gmail.com>
  Obtained from:	DragonflyBSD f4a9869feb646aafe72de6e5d61051a023a02676

Modified:
  head/usr.sbin/ppp/auth.c

Modified: head/usr.sbin/ppp/auth.c
==============================================================================
--- head/usr.sbin/ppp/auth.c	Mon Oct  2 23:12:02 2017	(r324224)
+++ head/usr.sbin/ppp/auth.c	Mon Oct  2 23:14:29 2017	(r324225)
@@ -125,13 +125,19 @@ auth_CheckPasswd(const char *name, const char *data, c
 #ifdef NOPAM
     /* Then look up the real password database */
     struct passwd *pw;
-    int result;
+    int result = 0;
     char *cryptpw;
+    
+    pw = getpwnam(name);
 
-    cryptpw = crypt(key, pw->pw_passwd);
-    result = (pw = getpwnam(name)) &&
-             (cryptpw == NULL || !strcmp(cryptpw, pw->pw_passwd));
+    if (pw) {
+      cryptpw = crypt(key, pw->pw_passwd);
+
+      result = (cryptpw != NULL) && !strcmp(cryptpw, pw->pw_passwd);
+    }
+
     endpwent();
+
     return result;
 #else /* !NOPAM */
     /* Then consult with PAM. */


More information about the svn-src-head mailing list