summaryrefslogtreecommitdiff
path: root/sys/isofs
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2012-09-10 11:11:01 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2012-09-10 11:11:01 +0000
commit2a1c47f2d9f2d1433ae48f64ec368b211b6786e2 (patch)
tree00a3a03b9a29a5e072374ac5b732685089b0c708 /sys/isofs
parentcf8106e329fdb32752921ec5380a309d42f22134 (diff)
Cleanup VFS mount string handling:
- Avoid using copyinstr() without checking the return value. - sys_mount() has already copied the path in, so pass this to the filesystem mount code so that it does not have to copy it in again. - Avoid copyinstr()/bzero() dance when we can simply bzero() and strlcpy(). ok krw@
Diffstat (limited to 'sys/isofs')
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c39
-rw-r--r--sys/isofs/udf/udf_vfsops.c18
2 files changed, 34 insertions, 23 deletions
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index 5d4434860f7..d5a7dc5b3b9 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vfsops.c,v 1.60 2011/07/04 20:35:35 deraadt Exp $ */
+/* $OpenBSD: cd9660_vfsops.c,v 1.61 2012/09/10 11:10:59 jsing Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */
/*-
@@ -134,34 +134,38 @@ cd9660_mount(mp, path, data, ndp, p)
struct nameidata *ndp;
struct proc *p;
{
- struct vnode *devvp;
+ struct iso_mnt *imp = NULL;
struct iso_args args;
- size_t size;
+ struct vnode *devvp;
+ char fspec[MNAMELEN];
int error;
- struct iso_mnt *imp = NULL;
-
- error = copyin(data, &args, sizeof (struct iso_args));
- if (error)
- return (error);
if ((mp->mnt_flag & MNT_RDONLY) == 0)
return (EROFS);
+ error = copyin(data, &args, sizeof(struct iso_args));
+ if (error)
+ return (error);
+
/*
* If updating, check whether changing from read-only to
* read/write; if there is no device name, that's all we do.
*/
if (mp->mnt_flag & MNT_UPDATE) {
imp = VFSTOISOFS(mp);
- if (args.fspec == 0)
+ if (args.fspec == NULL)
return (vfs_export(mp, &imp->im_export,
&args.export_info));
}
+
/*
* Not an update, or updating the name: look up the name
* and verify that it refers to a sensible block device.
*/
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
+ error = copyinstr(args.fspec, fspec, sizeof(fspec), NULL);
+ if (error)
+ return (error);
+ NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, p);
if ((error = namei(ndp)) != 0)
return (error);
devvp = ndp->ni_vp;
@@ -174,6 +178,7 @@ cd9660_mount(mp, path, data, ndp, p)
vrele(devvp);
return (ENXIO);
}
+
/*
* If mount by non-root, then verify that user has necessary
* permissions on the device.
@@ -200,13 +205,15 @@ cd9660_mount(mp, path, data, ndp, p)
return (error);
}
imp = VFSTOISOFS(mp);
- (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void)copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
+
+ bzero(mp->mnt_stat.f_mntonname, MNAMELEN);
+ strlcpy(mp->mnt_stat.f_mntonname, path, MNAMELEN);
+ bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
+ strlcpy(mp->mnt_stat.f_mntfromname, fspec, MNAMELEN);
bcopy(&args, &mp->mnt_stat.mount_info.iso_args, sizeof(args));
- (void)cd9660_statfs(mp, &mp->mnt_stat, p);
+
+ cd9660_statfs(mp, &mp->mnt_stat, p);
+
return (0);
}
diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c
index 5e13fb6a772..cb3fbe46e69 100644
--- a/sys/isofs/udf/udf_vfsops.c
+++ b/sys/isofs/udf/udf_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udf_vfsops.c,v 1.38 2011/07/04 20:35:35 deraadt Exp $ */
+/* $OpenBSD: udf_vfsops.c,v 1.39 2012/09/10 11:10:59 jsing Exp $ */
/*
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
@@ -122,7 +122,7 @@ udf_mount(struct mount *mp, const char *path, void *data,
{
struct vnode *devvp; /* vnode of the mount device */
struct udf_args args;
- size_t len;
+ char fspec[MNAMELEN];
int error;
if ((mp->mnt_flag & MNT_RDONLY) == 0) {
@@ -146,7 +146,11 @@ udf_mount(struct mount *mp, const char *path, void *data,
if (args.fspec == NULL)
return (EINVAL);
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
+ error = copyinstr(args.fspec, fspec, sizeof(fspec), NULL);
+ if (error)
+ return (error);
+
+ NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, p);
if ((error = namei(ndp)))
return (error);
@@ -180,10 +184,10 @@ udf_mount(struct mount *mp, const char *path, void *data,
/*
* Keep a copy of the mount information.
*/
- copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &len);
- bzero(mp->mnt_stat.f_mntonname + len, MNAMELEN - len);
- copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &len);
- bzero(mp->mnt_stat.f_mntfromname + len, MNAMELEN - len);
+ bzero(mp->mnt_stat.f_mntonname, MNAMELEN);
+ strlcpy(mp->mnt_stat.f_mntonname, path, MNAMELEN);
+ bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
+ strlcpy(mp->mnt_stat.f_mntfromname, fspec, MNAMELEN);
return (0);
};