From nobody@FreeBSD.org  Tue Oct 23 10:23:06 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 8046D7C1
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Oct 2012 10:23:06 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 690B38FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Oct 2012 10:23:06 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9NAN6o6091772
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Oct 2012 10:23:06 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q9NAN6XV091771;
	Tue, 23 Oct 2012 10:23:06 GMT
	(envelope-from nobody)
Message-Id: <201210231023.q9NAN6XV091771@red.freebsd.org>
Date: Tue, 23 Oct 2012 10:23:06 GMT
From: Erik Cederstrand <erik@cederstrand.dk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: chpass: Fix null pointer dereference
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172979
>Category:       bin
>Synopsis:       chpass(1): Fix null pointer dereference
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 23 10:30:01 UTC 2012
>Closed-Date:    Mon Nov 19 04:08:41 UTC 2012
>Last-Modified:  Mon Nov 19 04:08:41 UTC 2012
>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:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Tue Oct 23 15:41:51 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172979 
State-Changed-From-To: open->analyzed 
State-Changed-By: eadler 
State-Changed-When: Tue Nov 13 20:16:17 UTC 2012 
State-Changed-Why:  
awaiting approval or review prior to commit (no action needed from 
submitter) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172979 
State-Changed-From-To: analyzed->patched 
State-Changed-By: eadler 
State-Changed-When: Thu Nov 15 18:37:20 UTC 2012 
State-Changed-Why:  
committed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172979 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Mon Nov 19 04:08:40 UTC 2012 
State-Changed-Why:  
MFCed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172979 
>Unformatted:
