Date: Wed, 12 Apr 2000 18:00:03 -0700 (PDT) From: "Matthew D. Fuller" <fullermd@over-yonder.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/17958: pkg_delete runs away when given path with trailing / Message-ID: <200004130100.SAA04602@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/17958; it has been noted by GNATS.
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"
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200004130100.SAA04602>
