svn commit: r243081 - head/usr.bin/chpass

Eitan Adler eadler at FreeBSD.org
Thu Nov 15 15:06:18 UTC 2012


Author: eadler
Date: Thu Nov 15 15:06:18 2012
New Revision: 243081
URL: http://svnweb.freebsd.org/changeset/base/243081

Log:
  Avoid possible null deref if ypclnt_new returns null
  
  PR:		bin/172979
  Submitted by:	Erik Cederstrand <erik at cederstrand.dk>
  Approved by:	cperciva
  MFC after:	3 days

Modified:
  head/usr.bin/chpass/chpass.c

Modified: head/usr.bin/chpass/chpass.c
==============================================================================
--- head/usr.bin/chpass/chpass.c	Thu Nov 15 15:06:15 2012	(r243080)
+++ head/usr.bin/chpass/chpass.c	Thu Nov 15 15:06:18 2012	(r243081)
@@ -241,8 +241,11 @@ main(int argc, char *argv[])
 #ifdef YP
 	case _PWF_NIS:
 		ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host);
-		if (ypclnt == NULL ||
-		    ypclnt_connect(ypclnt) == -1 ||
+		if (ypclnt == NULL) {
+			warnx("ypclnt_new failed");
+			exit(1);
+		}
+		if (ypclnt_connect(ypclnt) == -1 ||
 		    ypclnt_passwd(ypclnt, pw, password) == -1) {
 			warnx("%s", ypclnt->error);
 			ypclnt_free(ypclnt);


More information about the svn-src-all mailing list