From owner-freebsd-bugs Wed Mar 5 22:00:08 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id WAA15647 for bugs-outgoing; Wed, 5 Mar 1997 22:00:08 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id WAA15612; Wed, 5 Mar 1997 22:00:04 -0800 (PST) Resent-Date: Wed, 5 Mar 1997 22:00:04 -0800 (PST) Resent-Message-Id: <199703060600.WAA15612@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, Received:(from nobody@localhost) by.freefall.freebsd.org.id.VAA15455;Wed; (8.8.5/8.8.5);, 5 Mar 1997 21:57:52.-0800 (PST) Message-Id: <199703060557.VAA15455@freefall.freebsd.org> Date: Wed, 5 Mar 1997 21:57:52 -0800 (PST) From: pius@iago.ienet.com To: freebsd-gnats-submit@freebsd.org X-Send-Pr-Version: www-1.0 Subject: bin/2893: pkg_delete segfaults when +CONTENTS doesn't set a prefix using @cwd Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2893 >Category: bin >Synopsis: pkg_delete segfaults when +CONTENTS doesn't set a prefix using @cwd >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Mar 5 22:00:02 PST 1997 >Last-Modified: >Originator: Pius Fischer >Organization: >Release: 3.0-CURRENT >Environment: FreeBSD iago.ienet.com 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Wed Mar 5 19:20:16 PST 1997 pius@iago.ienet.com:/usr/src/sys/compile/IAGO i386 >Description: Sorry to be so picky, this is a very small problem, but I encountered it when I wanted to remove the MH package (I wanted to do a fresh install of the MH port), but realized that for some reason there was no directory /var/db/pkg/mh-6.8.4/. So I just created it, copied the PLIST from the port to +CONTENTS, and typed "pkg_delete -v mh-6.8.4" which resulted in a coredump! The problem: +CONTENTS didn't contain the "@cwd /usr/local" because that gets added when you install the port or the package, but I had just copied the PLIST straight from the port. So pkg_delete segfaults because in perform.c it ends up doing a setenv(PKG_PREFIX_VNAME, NULL, 1) and setenv dereferences the NULL pointer! The correct behavior should probably be either to set the environment variable to "" or to print a warning message. >How-To-Repeat: Well, here's what I did: mkdir /var/db/pkg/mh-6.8.4 cd /var/db/pkg/mh-6.8.4 cp /usr/ports/mail/mh/pkg/PLIST +CONTENTS cd pkg_delete -v mh-6.8.4 >Fix: Well, perhaps one of these two patches should be applied: (1) --- perform.c.orig Wed Mar 5 21:19:30 1997 +++ perform.c Wed Mar 5 21:53:51 1997 @@ -94,7 +94,7 @@ read_plist(&Plist, cfile); fclose(cfile); setenv(PKG_PREFIX_VNAME, - (p = find_plist(&Plist, PLIST_CWD)) ? p->name : NULL, 1); + (p = find_plist(&Plist, PLIST_CWD)) ? p->name : "", 1); if (fexists(REQUIRE_FNAME)) { if (Verbose) printf("Executing 'require' script.\n"); (2) --- perform.c.orig Wed Mar 5 21:19:30 1997 +++ perform.c Wed Mar 5 21:54:46 1997 @@ -93,8 +93,12 @@ add_plist(&Plist, PLIST_CWD, Prefix); read_plist(&Plist, cfile); fclose(cfile); - setenv(PKG_PREFIX_VNAME, - (p = find_plist(&Plist, PLIST_CWD)) ? p->name : NULL, 1); + p = find_plist(&Plist, PLIST_CWD); + if (!p) { + whinge("Package '%s' doesn't have a prefix.", pkg); + return 1; + } + setenv(PKG_PREFIX_VNAME, p->name, 1); if (fexists(REQUIRE_FNAME)) { if (Verbose) printf("Executing 'require' script.\n"); >Audit-Trail: >Unformatted: