diff options
author | jkh <jkh@FreeBSD.org> | 1998-09-08 03:15:41 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1998-09-08 03:15:41 +0000 |
commit | a5f5454e47ca079b1b2a159e768c5465d17ee7a7 (patch) | |
tree | 63653b4cef5d4b351a1b2a0d6798b42ad32eefc3 /usr.sbin | |
parent | 8355921f3182d696d2091315ec085b5568a657d4 (diff) | |
download | FreeBSD-src-a5f5454e47ca079b1b2a159e768c5465d17ee7a7.zip FreeBSD-src-a5f5454e47ca079b1b2a159e768c5465d17ee7a7.tar.gz |
Fix bogus suffix stripping to be less naive.
PR: 3418
Noted by: pst
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_install/create/perform.c | 16 |
1 files changed, 7 insertions, 9 deletions
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); |