From owner-svn-src-all@FreeBSD.ORG Tue Jan 13 06:08:38 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 320C510656C0; Tue, 13 Jan 2009 06:08:38 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2103E8FC08; Tue, 13 Jan 2009 06:08:38 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0D68br5091811; Tue, 13 Jan 2009 06:08:37 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0D68blf091810; Tue, 13 Jan 2009 06:08:37 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <200901130608.n0D68blf091810@svn.freebsd.org> From: "David E. O'Brien" Date: Tue, 13 Jan 2009 06:08:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187130 - head/sbin/mount X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2009 06:08:38 -0000 Author: obrien Date: Tue Jan 13 06:08:37 2009 New Revision: 187130 URL: http://svn.freebsd.org/changeset/base/187130 Log: r187093 failed to keep the lifetime of the pointer suitable for reentrancy. Fix that. Also move the current buffer size into the 'cpa' structure. Modified: head/sbin/mount/mount.c Modified: head/sbin/mount/mount.c ============================================================================== --- head/sbin/mount/mount.c Tue Jan 13 05:50:22 2009 (r187129) +++ head/sbin/mount/mount.c Tue Jan 13 06:08:37 2009 (r187130) @@ -70,6 +70,7 @@ int debug, fstab_style, verbose; struct cpa { char **a; + ssize_t sz; int c; }; @@ -503,11 +504,9 @@ hasopt(const char *mntopts, const char * static void append_arg(struct cpa *sa, char *arg) { - static int a_sz; - - if (sa->c + 1 == a_sz) { - a_sz = a_sz == 0 ? 8 : a_sz * 2; - sa->a = realloc(sa->a, sizeof(sa->a) * a_sz); + if (sa->c + 1 == sa->sz) { + sa->sz = sa->sz == 0 ? 8 : sa->sz * 2; + sa->a = realloc(sa->a, sizeof(sa->a) * sa->sz); if (sa->a == NULL) errx(1, "realloc failed"); } @@ -518,11 +517,10 @@ int mountfs(const char *vfstype, const char *spec, const char *name, int flags, const char *options, const char *mntopts) { - struct cpa mnt_argv; struct statfs sf; int i, ret; char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX]; - static int mnt_argv_inited; + static struct cpa mnt_argv; /* resolve the mountpoint with realpath(3) */ (void)checkpath(name, mntpath); @@ -557,10 +555,6 @@ mountfs(const char *vfstype, const char /* Construct the name of the appropriate mount command */ (void)snprintf(execname, sizeof(execname), "mount_%s", vfstype); - if (!mnt_argv_inited) { - mnt_argv_inited++; - mnt_argv.a = NULL; - } mnt_argv.c = -1; append_arg(&mnt_argv, execname); mangle(optbuf, &mnt_argv);