Source-Changes-HG archive

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

[src/trunk]: src/sys/kern uiomove(9): Stronger assertions about iov array.



details:   https://anonhg.NetBSD.org/src/rev/817f62cf23f5
branches:  trunk
changeset: 374216:817f62cf23f5
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Apr 11 10:22:04 2023 +0000

description:
uiomove(9): Stronger assertions about iov array.

diffstat:

 sys/kern/subr_copy.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 3e07fafefeae -r 817f62cf23f5 sys/kern/subr_copy.c
--- a/sys/kern/subr_copy.c      Tue Apr 11 10:19:56 2023 +0000
+++ b/sys/kern/subr_copy.c      Tue Apr 11 10:22:04 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_copy.c,v 1.17 2023/02/24 11:02:27 riastradh Exp $ */
+/*     $NetBSD: subr_copy.c,v 1.18 2023/04/11 10:22:04 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008, 2019
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.17 2023/02/24 11:02:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_copy.c,v 1.18 2023/04/11 10:22:04 riastradh Exp $");
 
 #define        __UFETCHSTORE_PRIVATE
 #define        __UCAS_PRIVATE
@@ -112,10 +112,11 @@ uiomove(void *buf, size_t n, struct uio 
 
        KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE);
        while (n > 0 && uio->uio_resid) {
+               KASSERT(uio->uio_iovcnt > 0);
                iov = uio->uio_iov;
                cnt = iov->iov_len;
                if (cnt == 0) {
-                       KASSERT(uio->uio_iovcnt > 0);
+                       KASSERT(uio->uio_iovcnt > 1);
                        uio->uio_iov++;
                        uio->uio_iovcnt--;
                        continue;



Home | Main Index | Thread Index | Old Index