Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb kassert that we aren't overflowing the array.



details:   https://anonhg.NetBSD.org/src/rev/aec53d62302a
branches:  trunk
changeset: 821010:aec53d62302a
user:      maya <maya%NetBSD.org@localhost>
date:      Fri Jan 20 02:22:42 2017 +0000

description:
kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.

diffstat:

 sys/dev/usb/ukbd.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 4239804ae70a -r aec53d62302a sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c        Fri Jan 20 00:29:28 2017 +0000
+++ b/sys/dev/usb/ukbd.c        Fri Jan 20 02:22:42 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ukbd.c,v 1.134 2016/11/25 12:50:13 skrll Exp $        */
+/*      $NetBSD: ukbd.c,v 1.135 2017/01/20 02:22:42 maya Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.134 2016/11/25 12:50:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.135 2017/01/20 02:22:42 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -719,7 +719,10 @@
        int s;
        int nkeys, i, j;
        int key;
-#define ADDKEY(c) ibuf[nkeys++] = (c)
+#define ADDKEY(c) do { \
+    KASSERT(nkeys < MAXKEYS); \
+    ibuf[nkeys++] = (c); \
+} while (0)
 
 #ifdef UKBD_DEBUG
        /*



Home | Main Index | Thread Index | Old Index