From ben@narcissus.net  Wed Apr 12 12:41:11 2000
Return-Path: <ben@narcissus.net>
Received: from narcissus.net (narcissus.net [209.73.230.146])
	by hub.freebsd.org (Postfix) with ESMTP id 42E8837BD6C
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 12 Apr 2000 12:35:59 -0700 (PDT)
	(envelope-from ben@narcissus.net)
Received: by narcissus.net (Postfix, from userid 1000)
	id 7C88FA0; Wed, 12 Apr 2000 15:24:01 -0400 (EDT)
Message-Id: <20000412192401.7C88FA0@narcissus.net>
Date: Wed, 12 Apr 2000 15:24:01 -0400 (EDT)
From: ben@narcissus.net
Reply-To: ben@narcissus.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: pkg_delete runs away when given path with trailing /
X-Send-Pr-Version: 3.2

>Number:         17958
>Category:       bin
>Synopsis:       pkg_delete runs away when given path with trailing /
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 12 12:50:01 PDT 2000
>Closed-Date:    Tue Jun 20 14:55:42 PDT 2000
>Last-Modified:  Tue Jun 20 14:56:15 PDT 2000
>Originator:     Ben Rosengart
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
Blue Dingo
>Environment:

I cvsupped and rebuilt this system yesterday evening (around midnight
GMT).

>Description:

When running "pkg_delete w3m-ssl-0.1.7/", pkg_delete consumes 100% of
the CPU and does not complete.  I tried three times, with the same result.
The fourth time, I deleted the trailing slash, and pkg_delete worked fine.

I then tried the same with another package, but it deleted fine even
with the slash.  However, I am able to reproduce the problem with w3m-ssl.

>How-To-Repeat:

cd /usr/ports/www/w3m-ssl
make install
cd /var/db/pkg
pkg_delete w3m-ssl-0.1.7/

>Fix:

Workaround is to not use the trailing slash, I'd guess the fix has
something to do with the new code that was recently added to pkg_delete
to handle trailing slashes.  ;-)

>Release-Note:
>Audit-Trail:

From: "Matthew D. Fuller" <fullermd@futuresouth.com>
To: ben@narcissus.net
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/17958: pkg_delete runs away when given path with trailing /
Date: Wed, 12 Apr 2000 18:30:40 -0500

 On Wed, Apr 12, 2000 at 03:24:01PM -0400, a little birdie told me
 that ben@narcissus.net remarked
 > 
 > When running "pkg_delete w3m-ssl-0.1.7/", pkg_delete consumes 100% of
 > the CPU and does not complete.  I tried three times, with the same result.
 > The fourth time, I deleted the trailing slash, and pkg_delete worked fine.
 
 Icky.
 I wrote some of the code to do that, I'll take a look at it tonite if
 someone hasn't already.
 
 
 
 -- 
 Matthew Fuller     (MF4839)     |    fullermd@over-yonder.net
 Unix Systems Administrator      |    fullermd@futuresouth.com
 Specializing in FreeBSD         |    http://www.over-yonder.net/
 
 "The only reason I'm burning my candle at both ends, is because I
       haven't figured out how to light the middle yet"
 

From: "Matthew D. Fuller" <fullermd@over-yonder.net>
To: ben@narcissus.net
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/17958: pkg_delete runs away when given path with trailing /
Date: Wed, 12 Apr 2000 19:52:06 -0500

 On Wed, Apr 12, 2000 at 03:24:01PM -0400 I heard the voice of
 ben@narcissus.net, and lo! it spake thus:
 > 
 > When running "pkg_delete w3m-ssl-0.1.7/", pkg_delete consumes 100% of
 > the CPU and does not complete.  I tried three times, with the same result.
 > The fourth time, I deleted the trailing slash, and pkg_delete worked fine.
 
 OK, found it.
 It's freaking out on an isalpha() test in the loop because the second
 char is a number, not a letter.  The test is designed to allow
 'pkg_delete /var/db/pkg/foo-a.b/' by removing the leading directories, by
 continuing to whack off /'s until there no longer is one there.  In
 retrospect, I'm not sure why it's using the second char, but a quick test
 with the first char doesn't work either.  This patch appears to make it
 work for me.  pkg_info included in the patch as well.
 
 Notes:
 1 - This should be revisited sometime to figure out why I did this the
 way I did.  It doesn't work the more 'logical' way, and I know I did it
 for good reason, I just don't remember it.
 
 2 - pkg_info and pkg_delete code has possibly gratuitous style
 differences, and should be re-styled closer together sometime, just for
 aesthetics.  I won't say which style I like better, because it's the one
 that's frowned upon  ;)
 
 3 - This presently requies that all packages have pass either isalpha()
 or isdigit() for the second char.  I *THINK* all packages pass that
 criterion, but then, I previously thought they'd all pass isalpha(), so I
 could be wrong again.
 
 
 
 Index: delete/main.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.sbin/pkg_install/delete/main.c,v
 retrieving revision 1.17
 diff -u -r1.17 main.c
 --- main.c	2000/02/18 07:00:01	1.17
 +++ main.c	2000/04/13 00:41:47
 @@ -84,7 +84,8 @@
      /* Get all the remaining package names, if any */
      while (*argv) {
          if ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
 -            while (!isalpha(*(pkgs_split + 1))) {
 +            while ((!isalpha(*(pkgs_split + 1)))
 +					&& (!isdigit(*(pkgs_split+1)))) {
                  *pkgs_split = '\0';
                  if ((pkgs_split = rindex(*argv, (int) '/')) == NULL)
                      pkgs_split = *argv;
 Index: info/main.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.sbin/pkg_install/info/main.c,v
 retrieving revision 1.22
 diff -u -r1.22 main.c
 --- main.c	2000/01/18 01:45:54	1.22
 +++ main.c	2000/04/13 00:41:48
 @@ -148,7 +148,8 @@
      {
          if( (pkgs_split = rindex(*argv, (int) '/')) != NULL )
          {
 -            while( !isalpha(*(pkgs_split+1)) )
 +            while( (!isalpha(*(pkgs_split+1)))
 +					&& (!isdigit(*(pkgs_split+1))) )
              {
                  *pkgs_split = '\0';
                  if ( (pkgs_split = rindex(*argv, (int) '/')) == NULL)
 
 
 
 -- 
 Matthew Fuller     (MF4839)     |    fullermd@over-yonder.net
 Unix Systems Administrator      |    fullermd@futuresouth.com
 Specializing in FreeBSD         |    http://www.over-yonder.net/
 
 "The only reason I'm burning my candle at both ends, is because I
       haven't figured out how to light the middle yet"
 
State-Changed-From-To: open->closed 
State-Changed-By: nrahlstr 
State-Changed-When: Tue Jun 20 14:55:42 PDT 2000 
State-Changed-Why:  
Fixed in revision 1.19 of usr.sbin/pkg_install/delete/main.c by steve. 


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