From owner-freebsd-bugs@FreeBSD.ORG Sun Mar 14 00:30:08 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54D341065672 for ; Sun, 14 Mar 2010 00:30:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 323838FC14 for ; Sun, 14 Mar 2010 00:30:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o2E0U8tA070005 for ; Sun, 14 Mar 2010 00:30:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o2E0U8k3070002; Sun, 14 Mar 2010 00:30:08 GMT (envelope-from gnats) Resent-Date: Sun, 14 Mar 2010 00:30:08 GMT Resent-Message-Id: <201003140030.o2E0U8k3070002@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A2131065676 for ; 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 ; 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 ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/144723: [patch] port over coverity SA NULL deref warning fix for hexdump(1) from NetBSD PR X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2010 00:30:08 -0000 >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: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 14 00:30:07 UTC 2010 >Closed-Date: >Last-Modified: >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: >Unformatted: