misc/172979: chpass: Fix null pointer dereference

Erik Cederstrand erik at cederstrand.dk
Tue Oct 23 10:30:02 UTC 2012


>Number:         172979
>Category:       misc
>Synopsis:       chpass: Fix null pointer dereference
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 23 10:30:01 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Erik Cederstrand
>Release:        CURRENT
>Organization:
>Environment:
>Description:
Fix a null pointer dereference when ypclnt is NULL
>How-To-Repeat:

>Fix:
Break the condition into two parts.

Patch attached with submission follows:

Index: head/usr.bin/chpass/chpass.c
===================================================================
--- head/usr.bin/chpass/chpass.c	(revision 241876)
+++ head/usr.bin/chpass/chpass.c	(working copy)
@@ -241,8 +241,9 @@
 #ifdef YP
 	case _PWF_NIS:
 		ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host);
-		if (ypclnt == NULL ||
-		    ypclnt_connect(ypclnt) == -1 ||
+		if (ypclnt == NULL)
+			exit(1);
+		if (ypclnt_connect(ypclnt) == -1 ||
 		    ypclnt_passwd(ypclnt, pw, password) == -1) {
 			warnx("%s", ypclnt->error);
 			ypclnt_free(ypclnt);

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list