From c3b0a89c845e3a147a930ec2f0e7c8a04d5ba575 Mon Sep 17 00:00:00 2001 From: mlelstv Date: Tue, 6 Mar 2018 07:49:36 +0000 Subject: Fix cmap bounds checking. --- sys/dev/wsfb/genfb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/wsfb/genfb.c b/sys/dev/wsfb/genfb.c index 4a2afd02723..f4830b1f577 100644 --- a/sys/dev/wsfb/genfb.c +++ b/sys/dev/wsfb/genfb.c @@ -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 -__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 #include @@ -611,8 +611,9 @@ genfb_putcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm) #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, struct wsdisplay_cmap *cm) 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); -- cgit