From a5f5454e47ca079b1b2a159e768c5465d17ee7a7 Mon Sep 17 00:00:00 2001 From: jkh Date: Tue, 8 Sep 1998 03:15:41 +0000 Subject: Fix bogus suffix stripping to be less naive. PR: 3418 Noted by: pst --- usr.sbin/pkg_install/create/perform.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index c86a128..e9f0124 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -1,6 +1,6 @@ #ifndef lint static const char rcsid[] = - "$Id: perform.c,v 1.41 1998/02/16 17:16:28 jkh Exp $"; + "$Id: perform.c,v 1.42 1998/07/28 11:55:39 jkh Exp $"; #endif /* @@ -45,6 +45,7 @@ pkg_perform(char **pkgs) FILE *pkg_in, *fp; Package plist; char *suffix; /* What we tack on to the end of the finished package */ + int len; /* Preliminary setup */ sanity_check(); @@ -62,13 +63,10 @@ pkg_perform(char **pkgs) } plist.head = plist.tail = NULL; - /* Break the package name into base and desired suffix (if any) */ - if ((cp = rindex(pkg, '.')) != NULL) { - suffix = cp + 1; - *cp = '\0'; - } - else - suffix = "tgz"; + /* chop suffix off if already specified */ + len = strlen(pkg); + if (len > 4 && !strcmp(&pkg[len - 4], ".tgz")) + pkg[len - 4] = '\0'; /* Stick the dependencies, if any, at the top */ if (Pkgdeps) { @@ -174,7 +172,7 @@ pkg_perform(char **pkgs) cleanup(0), errx(2, "error while closing %s", CONTENTS_FNAME); /* And stick it into a tar ball */ - make_dist(home, pkg, suffix, &plist); + make_dist(home, pkg, "tgz", &plist); /* Cleanup */ free(Comment); -- cgit v1.1