diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2012-09-10 11:11:01 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2012-09-10 11:11:01 +0000 |
commit | 2a1c47f2d9f2d1433ae48f64ec368b211b6786e2 (patch) | |
tree | 00a3a03b9a29a5e072374ac5b732685089b0c708 /sys/isofs/udf/udf_vfsops.c | |
parent | cf8106e329fdb32752921ec5380a309d42f22134 (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/udf/udf_vfsops.c')
-rw-r--r-- | sys/isofs/udf/udf_vfsops.c | 18 |
1 files changed, 11 insertions, 7 deletions
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); }; |