[email protected]
[Top] [All Lists]

PERFORCE change 113889 for review

Subject: PERFORCE change 113889 for review
From: Michael Bushkov
Date: Fri, 2 Feb 2007 09:07:23 GMT
http://perforce.freebsd.org/chv.cgi?CH=113889

Change 113889 by [email protected]_nss_ldap_cached on 2007/02/02 09:06:21

        IFC

Affected files ...

.. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/stdlib/malloc.c#8 
integrate
.. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/sys/quotactl.2#3 
integrate
.. //depot/projects/soc2006/nss_ldap_cached/src/share/mk/bsd.libnames.mk#3 
integrate
.. //depot/projects/soc2006/nss_ldap_cached/src/usr.bin/quota/quota.c#2 
integrate
.. 
//depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/pkg_install/add/main.c#5 
integrate

Differences ...

==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/stdlib/malloc.c#8 
(text+ko) ====

@@ -185,7 +185,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.138 2006/12/23 00:18:51 
jasone Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.139 2007/01/31 22:54:19 
jasone Exp $");
 
 #include "libc_private.h"
 #ifdef MALLOC_DEBUG
@@ -550,6 +550,14 @@
        qr(arena_run_t) link;
 };
 
+/* Avoid pointer aliasing issues. */
+static inline arena_run_t *
+arena_bin_link(void *ptr)
+{
+
+       return ((arena_run_t *)ptr);
+}
+
 struct arena_bin_s {
        /*
         * Current run being used to service allocations of this bin's size
@@ -1318,7 +1326,7 @@
                        if (incr == size) {
                                ret = brk_cur;
                        } else {
-                               ret = (void *)(intptr_t)brk_cur + incr;
+                               ret = (void *)((intptr_t)brk_cur + incr);
                                incr += size;
                        }
 
@@ -1326,7 +1334,7 @@
                        if (brk_prev == brk_cur) {
                                /* Success. */
                                malloc_mutex_unlock(&brk_mtx);
-                               brk_max = (void *)(intptr_t)ret + size;
+                               brk_max = (void *)((intptr_t)ret + size);
                                goto RETURN;
                        }
                } while (brk_prev != (void *)-1);
@@ -1412,13 +1420,13 @@
                 * the sake of poorly designed multi-threaded programs.
                 */
                if (brk_cur == brk_max
-                   && (void *)(uintptr_t)chunk + size == brk_max
+                   && (void *)((uintptr_t)chunk + size) == brk_max
                    && sbrk(-(intptr_t)size) == brk_max) {
                        malloc_mutex_unlock(&brk_mtx);
                        if (brk_prev == brk_max) {
                                /* Success. */
-                               brk_prev = (void *)(intptr_t)brk_max
-                                   - (intptr_t)size;
+                               brk_prev = (void *)((intptr_t)brk_max
+                                   - (intptr_t)size);
                                brk_max = brk_prev;
                        }
                        goto RETURN;
@@ -1608,7 +1616,7 @@
                mask = run->regs_mask[i];
                if (mask != 0) {
                        /* Usable allocation found. */
-                       bit = ffs(mask) - 1;
+                       bit = ffs((int)mask) - 1;
 
                        regind = ((i << (SIZEOF_INT_2POW + 3)) + bit);
                        ret = (void *)&((char *)run)[bin->reg0_offset
@@ -1764,7 +1772,7 @@
        /* Update map for trailing pages. */
        map_offset += need_pages;
        while (map_offset < run_ind + total_pages) {
-               log2_run_pages = ffs(map_offset) - 1;
+               log2_run_pages = ffs((int)map_offset) - 1;
                run_pages = (1 << log2_run_pages);
 
                chunk->map[map_offset].free = true;
@@ -1848,7 +1856,7 @@
                 * of by "allocating" the leading pages.
                 */
                while (map_offset < (chunk_size >> pagesize_2pow)) {
-                       log2_run_pages = ffs(map_offset) - 1;
+                       log2_run_pages = ffs((int)map_offset) - 1;
                        run_pages = (1 << log2_run_pages);
 
                        chunk->map[map_offset].free = true;
@@ -1904,7 +1912,8 @@
                        assert(0);
                        break;
                case RUN_Q0:
-                       qr_before_insert((arena_run_t *)&bin->runs0, run, link);
+                       qr_before_insert(arena_bin_link(&bin->runs0), run,
+                           link);
                        run->free_max = bin->nregs - 1;
                        run->free_min = (bin->nregs >> 1) + 1;
                        assert(run->nfree <= run->free_max);
@@ -1912,7 +1921,7 @@
                        break;
                case RUN_Q25:
                        qr_remove(run, link);
-                       qr_before_insert((arena_run_t *)&bin->runs25, run,
+                       qr_before_insert(arena_bin_link(&bin->runs25), run,
                            link);
                        run->free_max = ((bin->nregs >> 2) * 3) - 1;
                        run->free_min = (bin->nregs >> 2) + 1;
@@ -1921,7 +1930,7 @@
                        break;
                case RUN_Q50:
                        qr_remove(run, link);
-                       qr_before_insert((arena_run_t *)&bin->runs50, run,
+                       qr_before_insert(arena_bin_link(&bin->runs50), run,
                            link);
                        run->free_max = (bin->nregs >> 1) - 1;
                        run->free_min = 1;
@@ -1985,7 +1994,8 @@
                        break;
                case RUN_Q0:
                        qr_remove(run, link);
-                       qr_before_insert((arena_run_t *)&bin->runs0, run, link);
+                       qr_before_insert(arena_bin_link(&bin->runs0), run,
+                           link);
                        run->free_max = bin->nregs - 1;
                        run->free_min = (bin->nregs >> 1) + 1;
                        assert(run->nfree <= run->free_max);
@@ -1993,7 +2003,7 @@
                        break;
                case RUN_Q25:
                        qr_remove(run, link);
-                       qr_before_insert((arena_run_t *)&bin->runs25, run,
+                       qr_before_insert(arena_bin_link(&bin->runs25), run,
                            link);
                        run->free_max = ((bin->nregs >> 2) * 3) - 1;
                        run->free_min = (bin->nregs >> 2) + 1;
@@ -2002,7 +2012,7 @@
                        break;
                case RUN_Q50:
                        qr_remove(run, link);
-                       qr_before_insert((arena_run_t *)&bin->runs50, run,
+                       qr_before_insert(arena_bin_link(&bin->runs50), run,
                            link);
                        run->free_max = (bin->nregs >> 1) - 1;
                        run->free_min = 1;
@@ -2010,7 +2020,7 @@
                        assert(run->nfree >= run->free_min);
                        break;
                case RUN_Q75:
-                       qr_before_insert((arena_run_t *)&bin->runs75, run,
+                       qr_before_insert(arena_bin_link(&bin->runs75), run,
                            link);
                        run->free_max = (bin->nregs >> 2) - 1;
                        run->free_min = 1;
@@ -2047,7 +2057,7 @@
         * large enough.  Look for a precise fit, but do not pass up a chunk
         * that has a run which is large enough to split.
         */
-       min_ind = ffs(size >> pagesize_2pow) - 1;
+       min_ind = ffs((int)(size >> pagesize_2pow)) - 1;
        RB_FOREACH(chunk, arena_chunk_tree_s, &arena->chunks) {
                for (i = min_ind;
                    i < (opt_chunk_2pow - pagesize_2pow);
@@ -2096,7 +2106,7 @@
        run_ind = (unsigned)(((uintptr_t)run - (uintptr_t)chunk)
            >> pagesize_2pow);
        run_pages = (size >> pagesize_2pow);
-       log2_run_pages = ffs(run_pages) - 1;
+       log2_run_pages = ffs((int)run_pages) - 1;
        assert(run_pages > 0);
 
        /* Subtract pages from count of pages used in chunk. */
@@ -2168,14 +2178,14 @@
        unsigned i, remainder;
 
        /* Look for a usable run. */
-       if ((run = qr_next((arena_run_t *)&bin->runs50, link))
-           != (arena_run_t *)&bin->runs50
-           || (run = qr_next((arena_run_t *)&bin->runs25, link))
-           != (arena_run_t *)&bin->runs25
-           || (run = qr_next((arena_run_t *)&bin->runs0, link))
-           != (arena_run_t *)&bin->runs0
-           || (run = qr_next((arena_run_t *)&bin->runs75, link))
-           != (arena_run_t *)&bin->runs75) {
+       if ((run = qr_next(arena_bin_link(&bin->runs50), link))
+           != arena_bin_link(&bin->runs50)
+           || (run = qr_next(arena_bin_link(&bin->runs25), link))
+           != arena_bin_link(&bin->runs25)
+           || (run = qr_next(arena_bin_link(&bin->runs0), link))
+           != arena_bin_link(&bin->runs0)
+           || (run = qr_next(arena_bin_link(&bin->runs75), link))
+           != arena_bin_link(&bin->runs75)) {
                /* run is guaranteed to have available space. */
                qr_remove(run, link);
                return (run);
@@ -2276,7 +2286,8 @@
                if (size < small_min) {
                        /* Tiny. */
                        size = pow2_ceil(size);
-                       bin = &arena->bins[ffs(size >> (tiny_min_2pow + 1))];
+                       bin = &arena->bins[ffs((int)(size >> (tiny_min_2pow +
+                           1)))];
 #if (!defined(NDEBUG) || defined(MALLOC_STATS))
                        /*
                         * Bin calculation is always correct, but we may need
@@ -2295,7 +2306,7 @@
                        /* Sub-page. */
                        size = pow2_ceil(size);
                        bin = &arena->bins[ntbins + nqbins
-                           + (ffs(size >> opt_small_max_2pow) - 2)];
+                           + (ffs((int)(size >> opt_small_max_2pow)) - 2)];
                }
                assert(size == bin->reg_size);
 
@@ -2375,8 +2386,8 @@
        /* Avoid moving the allocation if the size class would not change. */
        if (size < small_min) {
                if (oldsize < small_min &&
-                   ffs(pow2_ceil(size) >> (tiny_min_2pow + 1))
-                   == ffs(pow2_ceil(oldsize) >> (tiny_min_2pow + 1)))
+                   ffs((int)(pow2_ceil(size) >> (tiny_min_2pow + 1)))
+                   == ffs((int)(pow2_ceil(oldsize) >> (tiny_min_2pow + 1))))
                        goto IN_PLACE;
        } else if (size <= small_max) {
                if (oldsize >= small_min && oldsize <= small_max &&
@@ -2493,10 +2504,10 @@
        for (i = 0; i < ntbins; i++) {
                bin = &arena->bins[i];
                bin->runcur = NULL;
-               qr_new((arena_run_t *)&bin->runs0, link);
-               qr_new((arena_run_t *)&bin->runs25, link);
-               qr_new((arena_run_t *)&bin->runs50, link);
-               qr_new((arena_run_t *)&bin->runs75, link);
+               qr_new(arena_bin_link(&bin->runs0), link);
+               qr_new(arena_bin_link(&bin->runs25), link);
+               qr_new(arena_bin_link(&bin->runs50), link);
+               qr_new(arena_bin_link(&bin->runs75), link);
 
                bin->reg_size = (1 << (tiny_min_2pow + i));
 
@@ -2530,10 +2541,10 @@
        for (; i < ntbins + nqbins; i++) {
                bin = &arena->bins[i];
                bin->runcur = NULL;
-               qr_new((arena_run_t *)&bin->runs0, link);
-               qr_new((arena_run_t *)&bin->runs25, link);
-               qr_new((arena_run_t *)&bin->runs50, link);
-               qr_new((arena_run_t *)&bin->runs75, link);
+               qr_new(arena_bin_link(&bin->runs0), link);
+               qr_new(arena_bin_link(&bin->runs25), link);
+               qr_new(arena_bin_link(&bin->runs50), link);
+               qr_new(arena_bin_link(&bin->runs75), link);
 
                bin->reg_size = quantum * (i - ntbins + 1);
 
@@ -2564,10 +2575,10 @@
        for (; i < ntbins + nqbins + nsbins; i++) {
                bin = &arena->bins[i];
                bin->runcur = NULL;
-               qr_new((arena_run_t *)&bin->runs0, link);
-               qr_new((arena_run_t *)&bin->runs25, link);
-               qr_new((arena_run_t *)&bin->runs50, link);
-               qr_new((arena_run_t *)&bin->runs75, link);
+               qr_new(arena_bin_link(&bin->runs0), link);
+               qr_new(arena_bin_link(&bin->runs25), link);
+               qr_new(arena_bin_link(&bin->runs50), link);
+               qr_new(arena_bin_link(&bin->runs75), link);
 
                bin->reg_size = (small_max << (i - (ntbins + nqbins) + 1));
 
@@ -2940,7 +2951,7 @@
                malloc_mutex_lock(&chunks_mtx);
 
                /* Extract from tree of huge allocations. */
-               key.chunk = (void *)ptr;
+               key.chunk = __DECONST(void *, ptr);
                node = RB_FIND(chunk_tree_s, &huge, &key);
                assert(node != NULL);
 
@@ -3150,7 +3161,7 @@
                 * pagesize_2pow.
                 */
                assert(((result - 1) & result) == 0);
-               pagesize_2pow = ffs(result) - 1;
+               pagesize_2pow = ffs((int)result) - 1;
        }
 
        for (i = 0; i < 3; i++) {
@@ -3410,7 +3421,7 @@
                    89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149,
                    151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211,
                    223, 227, 229, 233, 239, 241, 251, 257, 263};
-               unsigned i, nprimes, parenas;
+               unsigned nprimes, parenas;
 
                /*
                 * Pick a prime number of hash arenas that is more than narenas
@@ -3559,6 +3570,7 @@
        size_t num_size;
 
        if (malloc_init()) {
+               num_size = 0;
                ret = NULL;
                goto RETURN;
        }

==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/sys/quotactl.2#3 
(text+ko) ====

@@ -29,7 +29,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"    @(#)quotactl.2  8.2 (Berkeley) 3/10/95
-.\" $FreeBSD: src/lib/libc/sys/quotactl.2,v 1.25 2007/01/09 00:28:15 imp Exp $
+.\" $FreeBSD: src/lib/libc/sys/quotactl.2,v 1.26 2007/02/01 02:31:02 mpp Exp $
 .\"
 .Dd March 5, 1999
 .Dt QUOTACTL 2
@@ -54,7 +54,7 @@
 .Fa cmd
 operates on the given filename
 .Fa path
-for the given user
+for the given user or group
 .Fa id .
 (NOTE: One should use the QCMD macro defined in
 .In ufs/ufs/quota.h
@@ -65,6 +65,12 @@
 may be given; its interpretation
 is discussed below with each command.
 .Pp
+For commands that use the
+.Fa id
+identifier, it must be either -1 or any positive value.
+The value of -1 indicates that the current UID or GID should be used.
+Any other negative value will return an error.
+.Pp
 Currently quotas are supported only for the
 .Dq ufs
 file system.
@@ -175,6 +181,15 @@
 and
 .Dv Q_SETQUOTA ,
 quotas are not currently enabled for this file system.
+.Pp
+The
+.Fa id
+argument to
+.Dv Q_GETQUOTA ,
+.Dv Q_SETQUOTA 
+or
+.Dv Q_SETUSE
+is a negative value.
 .It Bq Er EACCES
 In
 .Dv Q_QUOTAON ,

==== //depot/projects/soc2006/nss_ldap_cached/src/share/mk/bsd.libnames.mk#3 
(text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/mk/bsd.libnames.mk,v 1.99 2006/09/30 11:32:46 ru Exp $
+# $FreeBSD: src/share/mk/bsd.libnames.mk,v 1.100 2007/02/01 08:45:27 rafan Exp 
$
 
 # The include file <bsd.libnames.mk> define library names.
 # Other include files (e.g. bsd.prog.mk, bsd.lib.mk) include this
@@ -81,7 +81,6 @@
 LIBMILTER?=    ${DESTDIR}${LIBDIR}/libmilter.a
 .endif
 LIBMP?=                ${DESTDIR}${LIBDIR}/libmp.a
-LIBMYTINFO?=   "don't use LIBMYTINFO, use LIBNCURSES"
 .if ${MK_NCP} != "no"
 LIBNCP?=       ${DESTDIR}${LIBDIR}/libncp.a
 .endif

==== //depot/projects/soc2006/nss_ldap_cached/src/usr.bin/quota/quota.c#2 
(text+ko) ====

@@ -48,7 +48,7 @@
  * Disk quota reporting program.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/quota/quota.c,v 1.25 2006/10/21 23:57:38 ru 
Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/quota/quota.c,v 1.26 2007/02/01 08:37:44 mpp 
Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -88,11 +88,11 @@
 static const char *timeprt(time_t seconds);
 static struct quotause *getprivs(long id, int quotatype);
 static void usage(void);
-static void showuid(u_long uid);
-static void showgid(u_long gid);
-static void showusrname(char *name);
-static void showgrpname(char *name);
-static void showquotas(int type, u_long id, const char *name);
+static int showuid(u_long uid);
+static int showgid(u_long gid);
+static int showusrname(char *name);
+static int showgrpname(char *name);
+static int showquotas(int type, u_long id, const char *name);
 static void heading(int type, u_long id, const char *name, const char *tag);
 static int ufshasquota(struct fstab *fs, int type, char **qfnamep);
 static int getufsquota(struct fstab *fs, struct quotause *qup, long id,
@@ -113,7 +113,7 @@
 {
        int ngroups; 
        gid_t mygid, gidset[NGROUPS];
-       int i, ch, gflag = 0, uflag = 0;
+       int i, ch, gflag = 0, uflag = 0, errflag = 0;
 
        while ((ch = getopt(argc, argv, "ghlquv")) != -1) {
                switch(ch) {
@@ -145,39 +145,39 @@
                uflag++;
        if (argc == 0) {
                if (uflag)
-                       showuid(getuid());
+                       errflag += showuid(getuid());
                if (gflag) {
                        mygid = getgid();
                        ngroups = getgroups(NGROUPS, gidset);
                        if (ngroups < 0)
                                err(1, "getgroups");
-                       showgid(mygid);
+                       errflag += showgid(mygid);
                        for (i = 0; i < ngroups; i++)
                                if (gidset[i] != mygid)
-                                       showgid(gidset[i]);
+                                       errflag += showgid(gidset[i]);
                }
-               return(0);
+               return(errflag);
        }
        if (uflag && gflag)
                usage();
        if (uflag) {
                for (; argc > 0; argc--, argv++) {
                        if (alldigits(*argv))
-                               showuid(atoi(*argv));
+                               errflag += showuid(atoi(*argv));
                        else
-                               showusrname(*argv);
+                               errflag += showusrname(*argv);
                }
-               return(0);
+               return(errflag);
        }
        if (gflag) {
                for (; argc > 0; argc--, argv++) {
                        if (alldigits(*argv))
-                               showgid(atoi(*argv));
+                               errflag += showgid(atoi(*argv));
                        else
-                               showgrpname(*argv);
+                               errflag += showgrpname(*argv);
                }
        }
-       return(0);
+       return(errflag);
 }
 
 static void
@@ -194,7 +194,7 @@
 /*
  * Print out quotas for a specified user identifier.
  */
-static void
+static int
 showuid(u_long uid)
 {
        struct passwd *pwd = getpwuid(uid);
@@ -204,28 +204,28 @@
                name = "(no account)";
        else
                name = pwd->pw_name;
-       showquotas(USRQUOTA, uid, name);
+       return(showquotas(USRQUOTA, uid, name));
 }
 
 /*
  * Print out quotas for a specifed user name.
  */
-static void
+static int
 showusrname(char *name)
 {
        struct passwd *pwd = getpwnam(name);
 
        if (pwd == NULL) {
                warnx("%s: unknown user", name);
-               return;
+               return(1);
        }
-       showquotas(USRQUOTA, pwd->pw_uid, name);
+       return(showquotas(USRQUOTA, pwd->pw_uid, name));
 }
 
 /*
  * Print out quotas for a specified group identifier.
  */
-static void
+static int
 showgid(u_long gid)
 {
        struct group *grp = getgrgid(gid);
@@ -235,22 +235,22 @@
                name = "(no entry)";
        else
                name = grp->gr_name;
-       showquotas(GRPQUOTA, gid, name);
+       return(showquotas(GRPQUOTA, gid, name));
 }
 
 /*
  * Print out quotas for a specifed group name.
  */
-static void
+static int
 showgrpname(char *name)
 {
        struct group *grp = getgrnam(name);
 
        if (grp == NULL) {
                warnx("%s: unknown group", name);
-               return;
+               return(1);
        }
-       showquotas(GRPQUOTA, grp->gr_gid, name);
+       return(showquotas(GRPQUOTA, grp->gr_gid, name));
 }
 
 static void
@@ -264,14 +264,14 @@
        (void)printf(" %*s", len, buf);
 }
 
-static void
+static int
 showquotas(int type, u_long id, const char *name)
 {
        struct quotause *qup;
        struct quotause *quplist;
        const char *msgi, *msgb;
        const char *nam;
-       int lines = 0;
+       int lines = 0, overquota = 0;
        static time_t now;
 
        if (now == 0)
@@ -286,10 +286,13 @@
                        continue;
                msgi = (char *)0;
                if (qup->dqblk.dqb_ihardlimit &&
-                   qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_ihardlimit)
+                   qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_ihardlimit) {
+                       overquota++;
                        msgi = "File limit reached on";
+               }
                else if (qup->dqblk.dqb_isoftlimit &&
                    qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_isoftlimit) {
+                       overquota++;
                        if (qup->dqblk.dqb_itime > now)
                                msgi = "In file grace period on";
                        else
@@ -297,10 +300,13 @@
                }
                msgb = (char *)0;
                if (qup->dqblk.dqb_bhardlimit &&
-                   qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bhardlimit)
+                   qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bhardlimit) {
+                       overquota++;
                        msgb = "Block limit reached on";
+               }
                else if (qup->dqblk.dqb_bsoftlimit &&
                    qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bsoftlimit) {
+                       overquota++;
                        if (qup->dqblk.dqb_btime > now)
                                msgb = "In block grace period on";
                        else
@@ -357,6 +363,7 @@
        }
        if (!qflag && lines == 0)
                heading(type, id, name, "none");
+       return(overquota);
 }
 
 static void

==== 
//depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/pkg_install/add/main.c#5 
(text+ko) ====

@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/add/main.c,v 1.70 2006/09/29 
17:17:53 ru Exp $");
+__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/add/main.c,v 1.72 2007/02/01 
15:52:47 pav Exp $");
 
 #include <err.h>
 #include <sys/param.h>
@@ -47,9 +47,7 @@
 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 @@
     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+1) * 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 @@
            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);
                    }
                }
            }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "[email protected]"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 113889 for review, Michael Bushkov <=