Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sbus Fix an issue with FIOCSCURSOR FB_CUR_SETCMAP on...
details: https://anonhg.NetBSD.org/src/rev/e029fe7e5c01
branches: trunk
changeset: 997577:e029fe7e5c01
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Mar 13 22:12:46 2019 +0000
description:
Fix an issue with FIOCSCURSOR FB_CUR_SETCMAP on zx described here:
http://mail-index.netbsd.org/port-sparc/2019/02/11/msg002134.html
by replacing the fubyte() calls with copyin() into temporary buffers.
The other issue in zx_cursor_color() mentioned in that message will
be addressed separately.
diffstat:
sys/dev/sbus/zx.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diffs (53 lines):
diff -r 55c1c6450f1b -r e029fe7e5c01 sys/dev/sbus/zx.c
--- a/sys/dev/sbus/zx.c Wed Mar 13 20:56:33 2019 +0000
+++ b/sys/dev/sbus/zx.c Wed Mar 13 22:12:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: zx.c,v 1.42 2018/09/03 16:29:33 riastradh Exp $ */
+/* $NetBSD: zx.c,v 1.43 2019/03/13 22:12:46 thorpej Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.42 2018/09/03 16:29:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.43 2019/03/13 22:12:46 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -475,16 +475,24 @@
if (cu->cmap.index > 2 ||
cu->cmap.count > 2 - cu->cmap.index)
return (EINVAL);
- for (i = 0; i < cu->cmap.count; i++) {
- if ((v = fubyte(&cu->cmap.red[i])) < 0)
- return (EFAULT);
- sc->sc_curcmap[i + cu->cmap.index + 0] = v;
- if ((v = fubyte(&cu->cmap.green[i])) < 0)
- return (EFAULT);
- sc->sc_curcmap[i + cu->cmap.index + 2] = v;
- if ((v = fubyte(&cu->cmap.blue[i])) < 0)
- return (EFAULT);
- sc->sc_curcmap[i + cu->cmap.index + 4] = v;
+
+ uint8_t red[2], green[2], blue[2];
+ const u_int cnt = cu->cmap.count;
+
+ if (cnt &&
+ ((error = copyin(cu->cmap.red, red, cnt)) ||
+ (error = copyin(cu->cmap.green, green, cnt)) ||
+ (error = copyin(cu->cmap.blue, blue, cnt)))) {
+ return error;
+ }
+
+ for (i = 0; i < cnt; i++) {
+ sc->sc_curcmap[i + cu->cmap.index + 0] =
+ red[i];
+ sc->sc_curcmap[i + cu->cmap.index + 2] =
+ green[i];
+ sc->sc_curcmap[i + cu->cmap.index + 4] =
+ blue[i];
}
zx_cursor_color(sc);
}
Home |
Main Index |
Thread Index |
Old Index