Source-Changes-HG archive

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

[src/trunk]: src/lib/librumpuser Fix off-by-one



details:   https://anonhg.NetBSD.org/src/rev/2d9267455c8e
branches:  trunk
changeset: 1008482:2d9267455c8e
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Mar 24 01:13:41 2020 +0000

description:
Fix off-by-one

Before accessing array member, check whether it is not out of valid range.

Detected with ASan + RUMPKERNEL.

diffstat:

 lib/librumpuser/sp_common.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 93326772e90b -r 2d9267455c8e lib/librumpuser/sp_common.c
--- a/lib/librumpuser/sp_common.c       Mon Mar 23 23:28:47 2020 +0000
+++ b/lib/librumpuser/sp_common.c       Tue Mar 24 01:13:41 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: sp_common.c,v 1.39 2016/09/05 20:41:59 dholland Exp $ */
+/*      $NetBSD: sp_common.c,v 1.40 2020/03/24 01:13:41 kamil Exp $    */
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -342,7 +342,7 @@
                }
 
                /* ok, need to adjust iovec for potential next round */
-               while (n >= (ssize_t)iov[0].iov_len && iovlen) {
+               while (iovlen && n >= (ssize_t)iov[0].iov_len) {
                        n -= iov[0].iov_len;
                        iov++;
                        iovlen--;



Home | Main Index | Thread Index | Old Index