diff options
author | obrien <obrien@FreeBSD.org> | 2009-01-13 06:08:37 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2009-01-13 06:08:37 +0000 |
commit | 2819cd77d0091deea04843641ae0949c6c3bd196 (patch) | |
tree | 960af473b84016029ecf5f36c8206cffdd9c361b /sbin/mount | |
parent | 044ff6b386a70ff2cacd1c70ced4fa91e3beffe7 (diff) | |
download | FreeBSD-src-2819cd77d0091deea04843641ae0949c6c3bd196.zip FreeBSD-src-2819cd77d0091deea04843641ae0949c6c3bd196.tar.gz |
r187093 failed to keep the lifetime of the pointer suitable for reentrancy.
Fix that. Also move the current buffer size into the 'cpa' structure.
Diffstat (limited to 'sbin/mount')
-rw-r--r-- | sbin/mount/mount.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 47b355c..66b9c13 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -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 *option) 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 *spec, const char *name, int flags, /* 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); |