Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern support setsockopt() with larger data (up to MCLBYT...



details:   https://anonhg.NetBSD.org/src/rev/df721981c767
branches:  trunk
changeset: 532129:df721981c767
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri May 31 20:33:11 2002 +0000

description:
support setsockopt() with larger data (up to MCLBYTES).
From: Hitoshi Asaeda <Hitoshi.Asaeda%sophia.inria.fr@localhost>

diffstat:

 sys/kern/uipc_syscalls.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 5a1924d0019d -r df721981c767 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c  Fri May 31 20:10:45 2002 +0000
+++ b/sys/kern/uipc_syscalls.c  Fri May 31 20:33:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_syscalls.c,v 1.68 2002/02/11 18:11:43 jdolecek Exp $      */
+/*     $NetBSD: uipc_syscalls.c,v 1.69 2002/05/31 20:33:11 itojun Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.68 2002/02/11 18:11:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.69 2002/05/31 20:33:11 itojun Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_pipe.h"
@@ -777,19 +777,22 @@
        struct file     *fp;
        struct mbuf     *m;
        int             error;
+       unsigned int    l;
 
        m = NULL;
        /* getsock() will use the descriptor for us */
        if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
                return (error);
-       if (SCARG(uap, valsize) > MLEN) {
+       l = SCARG(uap, valsize);
+       if (l > MCLBYTES) {
                error = EINVAL;
                goto out;
        }
        if (SCARG(uap, val)) {
                m = m_get(M_WAIT, MT_SOOPTS);
-               error = copyin(SCARG(uap, val), mtod(m, caddr_t),
-                              SCARG(uap, valsize));
+               if (l > MLEN)
+                       MCLGET(m, M_WAIT);
+               error = copyin(SCARG(uap, val), mtod(m, caddr_t), l);
                if (error) {
                        (void) m_free(m);
                        goto out;



Home | Main Index | Thread Index | Old Index