diff options
author | steve <steve@FreeBSD.org> | 2000-05-14 19:54:04 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 2000-05-14 19:54:04 +0000 |
commit | 3726bbb199e100b7e2e620775f3a8dcd32f32c99 (patch) | |
tree | 96574887d358a24358d5b2bc5c25fa9f62ed2db2 /usr.sbin/pkg_install/delete/main.c | |
parent | a9498f1f9c981305536ca0c62b9bccaaa5d75aae (diff) | |
download | FreeBSD-src-3726bbb199e100b7e2e620775f3a8dcd32f32c99.zip FreeBSD-src-3726bbb199e100b7e2e620775f3a8dcd32f32c99.tar.gz |
Avoid infinite loops when given a package name like 'm4-1.1/'.
Approved by: jkh
Diffstat (limited to 'usr.sbin/pkg_install/delete/main.c')
-rw-r--r-- | usr.sbin/pkg_install/delete/main.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 4a75d11..3150118 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -87,24 +87,19 @@ main(int argc, char **argv) /* Get all the remaining package names, if any */ while (*argv) { - if ((pkgs_split = rindex(*argv, (int)'/')) != NULL) { - while (!isalpha(*(pkgs_split + 1))) { - *pkgs_split = '\0'; - if ((pkgs_split = rindex(*argv, (int) '/')) == NULL) - pkgs_split = *argv; - } - if (pkgs_split != NULL) { - if (*pkgs_split == '/') - pkgs_split++; - *pkgs = pkgs_split; - pkgs++; - } - } - else { - *pkgs = *argv; - pkgs++; - } - argv++; + while ((pkgs_split = rindex(*argv, (int)'/')) != NULL) { + *pkgs_split++ = '\0'; + /* + * If character after the '/' is alphanumeric, then we've found the + * package name. Otherwise we've come across a trailing '/' and + * need to continue our quest. + */ + if (isalpha(*pkgs_split)) { + *argv = pkgs_split; + break; + } + } + *pkgs++ = *argv++; } /* If no packages, yelp */ |