summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/add
diff options
context:
space:
mode:
authorade <ade@FreeBSD.org>2007-01-31 22:34:45 +0000
committerade <ade@FreeBSD.org>2007-01-31 22:34:45 +0000
commit9d9b2068537ade1d5f84cfaad0d577b8b556f565 (patch)
tree12164d8f87db70e5f15d9eab5c5f8c873a773013 /usr.sbin/pkg_install/add
parentdd7403e0de050efaf4124919bd6a3875fdcf19ee (diff)
downloadFreeBSD-src-9d9b2068537ade1d5f84cfaad0d577b8b556f565.zip
FreeBSD-src-9d9b2068537ade1d5f84cfaad0d577b8b556f565.tar.gz
Remove hard-coded limit (200) on maximum number of packages that can be
added with a single invocation of pkg_add, replacing it with something rather more dynamic. Approved by: portmgr (pav) Tested by: full pointyhat package run MFC after: 1 week
Diffstat (limited to 'usr.sbin/pkg_install/add')
-rw-r--r--usr.sbin/pkg_install/add/main.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 4d6b3c3..61caab1 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -47,9 +47,7 @@ char *Directory = NULL;
char FirstPen[FILENAME_MAX];
add_mode_t AddMode = NORMAL;
-#define MAX_PKGS 200
-char pkgnames[MAX_PKGS][MAXPATHLEN];
-char *pkgs[MAX_PKGS];
+char **pkgs;
struct {
int lowver; /* Lowest version number to match */
@@ -179,15 +177,13 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (argc > MAX_PKGS) {
- errx(1, "too many packages (max %d)", MAX_PKGS);
- }
-
if (AddMode != SLAVE) {
- for (ch = 0; ch < MAX_PKGS; pkgs[ch++] = NULL) ;
+ pkgs = (char **)malloc(argc * sizeof(char *));
+ for (ch = 0; ch <= argc; pkgs[ch++] = NULL) ;
/* Get all the remaining package names, if any */
for (ch = 0; *argv; ch++, argv++) {
+ char temp[MAXPATHLEN];
if (Remote) {
if ((packagesite = getpackagesite()) == NULL)
errx(1, "package name too long");
@@ -213,31 +209,27 @@ main(int argc, char **argv)
if (!strcmp(*argv, "-")) /* stdin? */
pkgs[ch] = (char *)"-";
else if (isURL(*argv)) { /* preserve URLs */
- if (strlcpy(pkgnames[ch], *argv, sizeof(pkgnames[ch]))
- >= sizeof(pkgnames[ch]))
+ if (strlcpy(temp, *argv, sizeof(temp)) >= sizeof(temp))
errx(1, "package name too long");
- pkgs[ch] = pkgnames[ch];
+ pkgs[ch] = strdup(temp);
}
else if ((Remote) && isURL(remotepkg)) {
- if (strlcpy(pkgnames[ch], remotepkg, sizeof(pkgnames[ch]))
- >= sizeof(pkgnames[ch]))
+ if (strlcpy(temp, remotepkg, sizeof(temp)) >= sizeof(temp))
errx(1, "package name too long");
- pkgs[ch] = pkgnames[ch];
+ pkgs[ch] = strdup(temp);
} else { /* expand all pathnames to fullnames */
if (fexists(*argv)) /* refers to a file directly */
- pkgs[ch] = realpath(*argv, pkgnames[ch]);
+ pkgs[ch] = strdup(realpath(*argv, temp));
else { /* look for the file in the expected places */
if (!(cp = fileFindByPath(NULL, *argv))) {
/* let pkg_do() fail later, so that error is reported */
- if (strlcpy(pkgnames[ch], *argv, sizeof(pkgnames[ch]))
- >= sizeof(pkgnames[ch]))
+ if (strlcpy(temp, *argv, sizeof(temp)) >= sizeof(temp))
errx(1, "package name too long");
- pkgs[ch] = pkgnames[ch];
+ pkgs[ch] = strdup(temp);
} else {
- if (strlcpy(pkgnames[ch], cp, sizeof(pkgnames[ch]))
- >= sizeof(pkgnames[ch]))
+ if (strlcpy(temp, cp, sizeof(temp)) >= sizeof(temp))
errx(1, "package name too long");
- pkgs[ch] = pkgnames[ch];
+ pkgs[ch] = strdup(temp);
}
}
}
OpenPOWER on IntegriCloud