summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2004-04-12 23:58:10 +0000
committertedu <tedu@openbsd.org>2004-04-12 23:58:10 +0000
commitdb68a6b1c406ab073f290361c3b62156fa51e4e8 (patch)
tree3a41ac58e61b60616ff83dfc971361dbcba09810
parentrelaying back bootp answers should work again (diff)
downloadwireguard-openbsd-db68a6b1c406ab073f290361c3b62156fa51e4e8.tar.xz
wireguard-openbsd-db68a6b1c406ab073f290361c3b62156fa51e4e8.zip
make sockargs take void *, combine a len check.
from pedro martelletto, ok markus@
-rw-r--r--sys/kern/uipc_syscalls.c20
-rw-r--r--sys/nfs/nfs_vfsops.c4
-rw-r--r--sys/sys/socketvar.h4
3 files changed, 11 insertions, 17 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 81f6010c492..9639c3b7e5c 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.58 2004/04/01 23:56:05 tedu Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.59 2004/04/12 23:58:10 tedu Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -115,7 +115,7 @@ sys_bind(p, v, retval)
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
- error = sockargs(&nam, (caddr_t)SCARG(uap, name), SCARG(uap, namelen),
+ error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
MT_SONAME);
if (error == 0) {
error = sobind((struct socket *)fp->f_data, nam);
@@ -284,7 +284,7 @@ sys_connect(p, v, retval)
FRELE(fp);
return (EALREADY);
}
- error = sockargs(&nam, (caddr_t)SCARG(uap, name), SCARG(uap, namelen),
+ error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
MT_SONAME);
if (error)
goto bad;
@@ -1091,11 +1091,7 @@ bad:
}
int
-sockargs(mp, buf, buflen, type)
- struct mbuf **mp;
- caddr_t buf;
- socklen_t buflen;
- int type;
+sockargs(struct mbuf **mp, const void *buf, size_t buflen, int type)
{
struct sockaddr *sa;
struct mbuf *m;
@@ -1103,11 +1099,10 @@ sockargs(mp, buf, buflen, type)
/*
* We can't allow socket names > UCHAR_MAX in length, since that
- * will overflow sa_len.
+ * will overflow sa_len. Also, control data more than MCLBYTES in
+ * length is just too much.
*/
- if (type == MT_SONAME && (u_int)buflen > UCHAR_MAX)
- return (EINVAL);
- if ((u_int)buflen > MCLBYTES)
+ if (buflen > (type == MT_SONAME ? UCHAR_MAX : MCLBYTES))
return (EINVAL);
/* Allocate an mbuf to hold the arguments. */
@@ -1128,7 +1123,6 @@ sockargs(mp, buf, buflen, type)
*mp = m;
if (type == MT_SONAME) {
sa = mtod(m, struct sockaddr *);
-
#if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
if (sa->sa_family == 0 && sa->sa_len < AF_MAX)
sa->sa_family = sa->sa_len;
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index fca16ff1f8c..79192812a3d 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vfsops.c,v 1.51 2003/08/14 07:46:40 mickey Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.52 2004/04/12 23:58:10 tedu Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */
/*
@@ -658,7 +658,7 @@ nfs_mount(mp, path, data, ndp, p)
return (error);
bzero(&hst[len], MNAMELEN - len);
/* sockargs() call must be after above copyin() calls */
- error = sockargs(&nam, (caddr_t)args.addr, args.addrlen, MT_SONAME);
+ error = sockargs(&nam, args.addr, args.addrlen, MT_SONAME);
if (error)
return (error);
args.fh = nfh;
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index cbf47961d26..7e3f71af05d 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socketvar.h,v 1.32 2003/09/23 16:51:13 millert Exp $ */
+/* $OpenBSD: socketvar.h,v 1.33 2004/04/12 23:58:10 tedu Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
@@ -295,7 +295,7 @@ int sosetopt(struct socket *so, int level, int optname,
struct mbuf *m0);
int soshutdown(struct socket *so, int how);
void sowakeup(struct socket *so, struct sockbuf *sb);
-int sockargs(struct mbuf **, caddr_t, socklen_t, int);
+int sockargs(struct mbuf **, const void *, size_t, int);
int sendit(struct proc *, int, struct msghdr *, int, register_t *);
int recvit(struct proc *, int, struct msghdr *, caddr_t,