From nobody@FreeBSD.org  Sun Mar 14 00:21:33 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1A2131065676
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 14 Mar 2010 00:21:33 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 09A2A8FC24
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 14 Mar 2010 00:21:33 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o2E0LWqN090873
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 14 Mar 2010 00:21:32 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o2E0LWMg090872;
	Sun, 14 Mar 2010 00:21:32 GMT
	(envelope-from nobody)
Message-Id: <201003140021.o2E0LWMg090872@www.freebsd.org>
Date: Sun, 14 Mar 2010 00:21:32 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] port over coverity SA NULL deref warning fix for hexdump(1) from NetBSD PR
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         144723
>Category:       bin
>Synopsis:       [patch] port over coverity SA NULL deref warning fix for hexdump(1) from NetBSD PR
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    brueffer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 14 00:30:07 UTC 2010
>Closed-Date:    Sat Mar 08 13:31:35 CET 2014
>Last-Modified:  Sat Mar 08 13:31:35 CET 2014
>Originator:     Garrett Cooper
>Release:        9-CURRENT
>Organization:
Cisco Systems, Inc.
>Environment:
FreeBSD bayonetta.localdomain 9.0-CURRENT FreeBSD 9.0-CURRENT #2: Thu Mar  4 13:16:39 PST 2010     gcooper@bayonetta.localdomain:/usr/obj/usr/src/sys/BAYONETTA  amd64
>Description:
As noted in the commit log for revision 1.19 of parse.c in NetBSD's cvs:

Simplify the way the end of a singly linked list is followed (for adding items) so it is more obvious that we aren't going to indirect through a null pointer.
Fixes coverty SID:101
>How-To-Repeat:
n/a
>Fix:
See attached patch.

Patch attached with submission follows:

Index: parse.c
===================================================================
--- parse.c	(revision 205137)
+++ parse.c	(working copy)
@@ -214,7 +214,6 @@
 	int nconv, prec;
 	size_t len;
 
-	nextpr = NULL;
 	prec = 0;
 
 	for (fu = fs->nextfu; fu; fu = fu->nextfu) {
@@ -222,13 +221,9 @@
 		 * Break each format unit into print units; each conversion
 		 * character gets its own.
 		 */
+		nextpr = &fu->nextpr;
 		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
-			if ((pr = calloc(1, sizeof(PR))) == NULL)
-				err(1, NULL);
-			if (!fu->nextpr)
-				fu->nextpr = pr;
-			else
-				*nextpr = pr;
+			*nextpr = pr;
 
 			/* Skip preceding text and up to the next % sign. */
 			for (p1 = fmtp; *p1 && *p1 != '%'; ++p1);


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: brueffer 
State-Changed-When: Sat Feb 22 11:16:11 CET 2014 
State-Changed-Why:  
Patch committed (minus the calloc removal), thanks! 


Responsible-Changed-From-To: freebsd-bugs->brueffer 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Sat Feb 22 11:16:11 CET 2014 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144723 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/144723: commit references a PR
Date: Sat, 22 Feb 2014 10:15:35 +0000 (UTC)

 Author: brueffer
 Date: Sat Feb 22 10:15:27 2014
 New Revision: 262333
 URL: http://svnweb.freebsd.org/changeset/base/262333
 
 Log:
   Simplify the way the end of a singly linked list is followed (for adding
   items), so it is more obvious that we aren't going to indirect through
   a NULL pointer.
   
   PR:		144723
   Submitted by:	Garrett Cooper <yaneurabeya at gmail.com>
   Obtained from:	NetBSD r1.19
   MFC after:	2 weeks
 
 Modified:
   head/usr.bin/hexdump/parse.c
 
 Modified: head/usr.bin/hexdump/parse.c
 ==============================================================================
 --- head/usr.bin/hexdump/parse.c	Sat Feb 22 09:53:17 2014	(r262332)
 +++ head/usr.bin/hexdump/parse.c	Sat Feb 22 10:15:27 2014	(r262333)
 @@ -210,7 +210,6 @@ rewrite(FS *fs)
  	int nconv, prec;
  	size_t len;
  
 -	nextpr = NULL;
  	prec = 0;
  
  	for (fu = fs->nextfu; fu; fu = fu->nextfu) {
 @@ -218,13 +217,11 @@ rewrite(FS *fs)
  		 * Break each format unit into print units; each conversion
  		 * character gets its own.
  		 */
 +		nextpr = &fu->nextpr;
  		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
  			if ((pr = calloc(1, sizeof(PR))) == NULL)
  				err(1, NULL);
 -			if (!fu->nextpr)
 -				fu->nextpr = pr;
 -			else
 -				*nextpr = pr;
 +			*nextpr = pr;
  
  			/* Skip preceding text and up to the next % sign. */
  			for (p1 = fmtp; *p1 && *p1 != '%'; ++p1);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/144723: commit references a PR
Date: Sat,  8 Mar 2014 12:25:57 +0000 (UTC)

 Author: brueffer
 Date: Sat Mar  8 12:25:45 2014
 New Revision: 262927
 URL: http://svnweb.freebsd.org/changeset/base/262927
 
 Log:
   MFC: r262333
   
   Simplify the way the end of a singly linked list is followed (for adding
   items), so it is more obvious that we aren't going to indirect through
   a NULL pointer.
   
   PR:             144723
   Submitted by:   Garrett Cooper <yaneurabeya at gmail.com>
   Obtained from:  NetBSD r1.19
 
 Modified:
   stable/9/usr.bin/hexdump/parse.c
 Directory Properties:
   stable/9/usr.bin/hexdump/   (props changed)
 
 Modified: stable/9/usr.bin/hexdump/parse.c
 ==============================================================================
 --- stable/9/usr.bin/hexdump/parse.c	Sat Mar  8 12:24:47 2014	(r262926)
 +++ stable/9/usr.bin/hexdump/parse.c	Sat Mar  8 12:25:45 2014	(r262927)
 @@ -210,7 +210,6 @@ rewrite(FS *fs)
  	int nconv, prec;
  	size_t len;
  
 -	nextpr = NULL;
  	prec = 0;
  
  	for (fu = fs->nextfu; fu; fu = fu->nextfu) {
 @@ -218,13 +217,11 @@ rewrite(FS *fs)
  		 * Break each format unit into print units; each conversion
  		 * character gets its own.
  		 */
 +		nextpr = &fu->nextpr;
  		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
  			if ((pr = calloc(1, sizeof(PR))) == NULL)
  				err(1, NULL);
 -			if (!fu->nextpr)
 -				fu->nextpr = pr;
 -			else
 -				*nextpr = pr;
 +			*nextpr = pr;
  
  			/* Skip preceding text and up to the next % sign. */
  			for (p1 = fmtp; *p1 && *p1 != '%'; ++p1);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/144723: commit references a PR
Date: Sat,  8 Mar 2014 12:25:05 +0000 (UTC)

 Author: brueffer
 Date: Sat Mar  8 12:24:47 2014
 New Revision: 262926
 URL: http://svnweb.freebsd.org/changeset/base/262926
 
 Log:
   MFC: r262333
   
   Simplify the way the end of a singly linked list is followed (for adding
   items), so it is more obvious that we aren't going to indirect through
   a NULL pointer.
   
   PR:		144723
   Submitted by:	Garrett Cooper <yaneurabeya at gmail.com>
   Obtained from:	NetBSD r1.19
 
 Modified:
   stable/10/usr.bin/hexdump/parse.c
 Directory Properties:
   stable/10/   (props changed)
 
 Modified: stable/10/usr.bin/hexdump/parse.c
 ==============================================================================
 --- stable/10/usr.bin/hexdump/parse.c	Sat Mar  8 06:06:50 2014	(r262925)
 +++ stable/10/usr.bin/hexdump/parse.c	Sat Mar  8 12:24:47 2014	(r262926)
 @@ -210,7 +210,6 @@ rewrite(FS *fs)
  	int nconv, prec;
  	size_t len;
  
 -	nextpr = NULL;
  	prec = 0;
  
  	for (fu = fs->nextfu; fu; fu = fu->nextfu) {
 @@ -218,13 +217,11 @@ rewrite(FS *fs)
  		 * Break each format unit into print units; each conversion
  		 * character gets its own.
  		 */
 +		nextpr = &fu->nextpr;
  		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
  			if ((pr = calloc(1, sizeof(PR))) == NULL)
  				err(1, NULL);
 -			if (!fu->nextpr)
 -				fu->nextpr = pr;
 -			else
 -				*nextpr = pr;
 +			*nextpr = pr;
  
  			/* Skip preceding text and up to the next % sign. */
  			for (p1 = fmtp; *p1 && *p1 != '%'; ++p1);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/144723: commit references a PR
Date: Sat,  8 Mar 2014 12:26:24 +0000 (UTC)

 Author: brueffer
 Date: Sat Mar  8 12:26:17 2014
 New Revision: 262928
 URL: http://svnweb.freebsd.org/changeset/base/262928
 
 Log:
   MFC: r262333
   
   Simplify the way the end of a singly linked list is followed (for adding
   items), so it is more obvious that we aren't going to indirect through
   a NULL pointer.
   
   PR:             144723
   Submitted by:   Garrett Cooper <yaneurabeya at gmail.com>
   Obtained from:  NetBSD r1.19
 
 Modified:
   stable/8/usr.bin/hexdump/parse.c
 Directory Properties:
   stable/8/usr.bin/hexdump/   (props changed)
 
 Modified: stable/8/usr.bin/hexdump/parse.c
 ==============================================================================
 --- stable/8/usr.bin/hexdump/parse.c	Sat Mar  8 12:25:45 2014	(r262927)
 +++ stable/8/usr.bin/hexdump/parse.c	Sat Mar  8 12:26:17 2014	(r262928)
 @@ -214,7 +214,6 @@ rewrite(FS *fs)
  	int nconv, prec;
  	size_t len;
  
 -	nextpr = NULL;
  	prec = 0;
  
  	for (fu = fs->nextfu; fu; fu = fu->nextfu) {
 @@ -222,13 +221,11 @@ rewrite(FS *fs)
  		 * Break each format unit into print units; each conversion
  		 * character gets its own.
  		 */
 +		nextpr = &fu->nextpr;
  		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
  			if ((pr = calloc(1, sizeof(PR))) == NULL)
  				err(1, NULL);
 -			if (!fu->nextpr)
 -				fu->nextpr = pr;
 -			else
 -				*nextpr = pr;
 +			*nextpr = pr;
  
  			/* Skip preceding text and up to the next % sign. */
  			for (p1 = fmtp; *p1 && *p1 != '%'; ++p1);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brueffer 
State-Changed-When: Sat Mar 8 13:31:16 CET 2014 
State-Changed-Why:  
Merge to stable branches done. 

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