summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-10-12 09:58:06 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-10-12 09:58:06 +0000
commit8727104b8eb8d058d7d16584a6194d30093ccbe1 (patch)
tree78315dc09ee1f1865fce68b918c61658ed8bcacc /sys/kern
parent56643a0b05f07deec6b0c63aedb0936b5e494cd8 (diff)
allow buflen > MLEN for !SO_NAME case (like ancillary data, necessary for
IPv6 advanced API). sync with netbsd.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_syscalls.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 0beecbb5650..613f1e969d0 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.31 2000/09/27 16:13:46 mickey Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.32 2000/10/12 09:58:05 itojun Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -1031,17 +1031,24 @@ sockargs(mp, buf, buflen, type)
register struct mbuf *m;
int error;
- if (buflen > MLEN) {
-#ifdef COMPAT_OLDSOCK
- if (type == MT_SONAME && buflen <= 112)
- buflen = MLEN; /* unix domain compat. hack */
- else
-#endif
+ /*
+ * We can't allow socket names > UCHAR_MAX in length, since that
+ * will overflow sa_len.
+ */
+ if (type == MT_SONAME && (u_int)buflen > UCHAR_MAX)
return (EINVAL);
- }
+ if ((u_int)buflen > MCLBYTES)
+ return (EINVAL);
+
+ /* Allocate an mbuf to hold the arguments. */
m = m_get(M_WAIT, type);
- if (m == NULL)
- return (ENOBUFS);
+ if ((u_int)buflen > MLEN) {
+ MCLGET(m, M_WAITOK);
+ if ((m->m_flags & M_EXT) == 0) {
+ m_free(m);
+ return ENOBUFS;
+ }
+ }
m->m_len = buflen;
error = copyin(buf, mtod(m, caddr_t), buflen);
if (error) {