| Summary: | pkg_delete runs away when given path with trailing / | ||
|---|---|---|---|
| Product: | Base System | Reporter: | ben <ben> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.0-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
ben
2000-04-12 20:50:01 UTC
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" 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 Fixed in revision 1.19 of usr.sbin/pkg_install/delete/main.c by steve. |