From nobody@FreeBSD.org  Fri Aug  9 08:07:25 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E68BD37B400
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Aug 2002 08:07:25 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id AA5C543E70
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Aug 2002 08:07:25 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g79F7KOT042570
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 9 Aug 2002 08:07:20 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g79F7K29042568;
	Fri, 9 Aug 2002 08:07:20 -0700 (PDT)
Message-Id: <200208091507.g79F7K29042568@www.freebsd.org>
Date: Fri, 9 Aug 2002 08:07:20 -0700 (PDT)
From: Mamoru IWAKI <iwaki@bc.niigata-u.ac.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pkg_info core-dumps for old style +CONTENTS file
X-Send-Pr-Version: www-1.0

>Number:         41482
>Category:       bin
>Synopsis:       pkg_info core-dumps for old style +CONTENTS file
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    sobomax
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 09 08:10:08 PDT 2002
>Closed-Date:    Fri Aug 30 05:11:45 PDT 2002
>Last-Modified:  Fri Aug 30 05:11:45 PDT 2002
>Originator:     Mamoru IWAKI
>Release:        FreeBSD 4.6-STABLE
>Organization:
Niigata University
>Environment:
FreeBSD mi000.merlin.gs.niigata-u.ac.jp 4.6-STABLE FreeBSD 4.6-STABLE #0: Thu Aug  8 00:48:44 JST 2002     root@mi000.merlin.gs.niigata-u.ac.jp:/usr1/obj/amd/mi004/home2/FreeBSD-src/stable4/src/sys/MI  i386
>Description:
Calling /usr/sbin/pkg_info with oprion -o core-dumps when the corresponding +CONTENTS file doesn't have any line of "@comment ORIGIN:".  The PR ports/40975 will have close relation to this problem.  
>How-To-Repeat:

>Fix:
My Guess: Package plist; in /usr/src/usr.sbin/pkg_install/info/perform.c is not properly set but used to print out its field for origin, under the lack of "@comment ORIGIN:".  
>Release-Note:
>Audit-Trail:

From: Brad Johnson <bjohnson@got.wedgie.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc: iwaki@bc.niigata-u.ac.jp
Subject: Re: bin/41482: pkg_info core-dumps for old style +CONTENTS file
Date: Fri, 9 Aug 2002 23:12:43 -0400 (EDT)

 Actually... I noticed this too and decided to do a little digging...
 
 A new "origin" char* member of the Package structure was recently added on
 8/2/2002, presumably to assist in adding the "search for packages by
 origin" feature. However, this origin char* never gets initialized... so
 if your package/port is old style and doesn't have an origin, your
 pkg_info -o will seg fault.
 
 I added:
 
 p->origin = NULL;
 
 near the beginning of the add_plist function in lib/plist.c (which starts
 at line 32), recompiled, and everything started working again. Not sure if
 that's the best place for the initialization to go, but since that seems
 to be the only function that ever writes to the origin variable, it seems
 as good as any.
 
 Hope that helps!
 Brad Johnson
 

From: Brad Johnson <bjohnson@got.wedgie.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc: iwaki@bc.niigata-u.ac.jp
Subject: Re: bin/41482: pkg_info core-dumps for old style +CONTENTS file
Date: Mon, 12 Aug 2002 20:35:24 -0400 (EDT)

 Hm... silly me...
 
 In my "fix" of this problem by setting p->origin to NULL in lib/plist.c, I
 fixed the seg fault, but I also broke the -o functionality of
 pkg_info!!
 
 The initialization of origin should happen at the beginning of the
 read_plist function, not add_plist as I originally suggested. I made the
 fix on mine and pkg_info started working the way it was supposed to
 without core dumps.
 
 So on line 263 of lib/plist.c, I added:
 
 pkg->origin = NULL;
 
 Sorry for not picking that up earlier; it was my first time looking at the
 code.
 
 - Brad Johnson
 
State-Changed-From-To: open->patched 
State-Changed-By: knu 
State-Changed-When: Mon Aug 19 18:17:40 JST 2002 
State-Changed-Why:  
Sobomax committed the fix to 5-CURRENT.  A due MFC to RELENG_4 will follow. 

However, note that there is no hope that it will be MFC'd to RELENG_4_[456] 
since re@ seem to want only security related fixes to be MFC'd to these 
branches.  So RELENG_4_[456] users must check out src/usr.sbin/pkg_install 
of RELENG_4 if they want to manipulate packages properly.  Sorry for the 
inconvenience. 


Responsible-Changed-From-To: freebsd-bugs->sobomax 
Responsible-Changed-By: knu 
Responsible-Changed-When: Mon Aug 19 18:17:40 JST 2002 
Responsible-Changed-Why:  
Sobomax committed the fix to 5-CURRENT.  A due MFC to RELENG_4 will follow. 

However, note that there is no hope that it will be MFC'd to RELENG_4_[456] 
since re@ seem to want only security related fixes to be MFC'd to these 
branches.  So RELENG_4_[456] users must check out src/usr.sbin/pkg_install 
of RELENG_4 if they want to manipulate packages properly.  Sorry for the 
inconvenience. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41482 
State-Changed-From-To: patched->closed 
State-Changed-By: sobomax 
State-Changed-When: Fri Aug 30 05:11:02 PDT 2002 
State-Changed-Why:  
The patch already MFC'ed. Please recvsup your sources, compile/install a world 
and you should be fine. 

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