Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wsfb Fix cmap bounds checking.



details:   https://anonhg.NetBSD.org/src/rev/eb5fc74721e3
branches:  trunk
changeset: 321201:eb5fc74721e3
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Tue Mar 06 07:49:36 2018 +0000

description:
Fix cmap bounds checking.

diffstat:

 sys/dev/wsfb/genfb.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r efcaa4548ffe -r eb5fc74721e3 sys/dev/wsfb/genfb.c
--- a/sys/dev/wsfb/genfb.c      Tue Mar 06 07:45:38 2018 +0000
+++ b/sys/dev/wsfb/genfb.c      Tue Mar 06 07:49:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfb.c,v 1.62 2018/01/21 04:20:10 christos Exp $ */
+/*     $NetBSD: genfb.c,v 1.63 2018/03/06 07:49:36 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.62 2018/01/21 04:20:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.63 2018/03/06 07:49:36 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -611,8 +611,9 @@
 #ifdef GENFB_DEBUG
        aprint_debug("putcmap: %d %d\n",index, count);
 #endif
-       if (index + count > 256)
+       if (index >= 256 || count > 256 || index + count > 256)
                return EINVAL;
+
        error = copyin(cm->red, &rbuf[index], count);
        if (error)
                return error;
@@ -646,7 +647,7 @@
        u_int count = cm->count;
        int error;
 
-       if (index >= 255 || count > 256 || index + count > 256)
+       if (index >= 256 || count > 256 || index + count > 256)
                return EINVAL;
 
        error = copyout(&sc->sc_cmap_red[index],   cm->red,   count);



Home | Main Index | Thread Index | Old Index