Module Name:    src
Committed By:   maya
Date:           Fri Jan 20 02:22:42 UTC 2017

Modified Files:
        src/sys/dev/usb: ukbd.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/usb/ukbd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.134 src/sys/dev/usb/ukbd.c:1.135
--- src/sys/dev/usb/ukbd.c:1.134	Fri Nov 25 12:50:13 2016
+++ src/sys/dev/usb/ukbd.c	Fri Jan 20 02:22:42 2017
@@ -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 @@ ukbd_decode(struct ukbd_softc *sc, struc
 	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
 	/*

Reply via email to