Module Name:    src
Committed By:   mlelstv
Date:           Tue Mar  6 07:49:36 UTC 2018

Modified Files:
        src/sys/dev/wsfb: genfb.c

Log Message:
Fix cmap bounds checking.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/wsfb/genfb.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/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.62 src/sys/dev/wsfb/genfb.c:1.63
--- src/sys/dev/wsfb/genfb.c:1.62	Sun Jan 21 04:20:10 2018
+++ src/sys/dev/wsfb/genfb.c	Tue Mar  6 07:49:36 2018
@@ -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 @@ genfb_putcmap(struct genfb_softc *sc, st
 #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 @@ genfb_getcmap(struct genfb_softc *sc, st
 	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);

Reply via email to