Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Don't overwrite the user iov pointer in sendmmsg. M...



details:   https://anonhg.NetBSD.org/src/rev/22397985a157
branches:  trunk
changeset: 341352:22397985a157
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 01 17:23:36 2015 +0000

description:
Don't overwrite the user iov pointer in sendmmsg. Make the send and receive
code look the same.

diffstat:

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

diffs (51 lines):

diff -r bb9cf807c82c -r 22397985a157 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c  Sun Nov 01 15:21:42 2015 +0000
+++ b/sys/kern/uipc_syscalls.c  Sun Nov 01 17:23:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_syscalls.c,v 1.180 2015/08/24 22:21:26 pooka Exp $        */
+/*     $NetBSD: uipc_syscalls.c,v 1.181 2015/11/01 17:23:36 christos Exp $     */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.180 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.181 2015/11/01 17:23:36 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pipe.h"
@@ -560,10 +560,10 @@
                        if (error)
                                goto bad;
                }
-               mp->msg_iov = iov;
-       }
+               auio.uio_iov = iov;
+       } else
+               auio.uio_iov = mp->msg_iov;
 
-       auio.uio_iov = mp->msg_iov;
        auio.uio_iovcnt = mp->msg_iovlen;
        auio.uio_rw = UIO_WRITE;
        auio.uio_offset = 0;                    /* XXX */
@@ -571,7 +571,8 @@
        KASSERT(l == curlwp);
        auio.uio_vmspace = l->l_proc->p_vmspace;
 
-       for (i = 0, tiov = mp->msg_iov; i < mp->msg_iovlen; i++, tiov++) {
+       tiov = auio.uio_iov;
+       for (i = 0; i < auio.uio_iovcnt; i++, tiov++) {
                /*
                 * Writes return ssize_t because -1 is returned on error.
                 * Therefore, we must restrict the length to SSIZE_MAX to
@@ -951,7 +952,7 @@
        auio.uio_vmspace = l->l_proc->p_vmspace;
 
        tiov = auio.uio_iov;
-       for (i = 0; i < mp->msg_iovlen; i++, tiov++) {
+       for (i = 0; i < auio.uio_iovcnt; i++, tiov++) {
                /*
                 * Reads return ssize_t because -1 is returned on error.
                 * Therefore we must restrict the length to SSIZE_MAX to



Home | Main Index | Thread Index | Old Index