diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2011-03-03 21:48:50 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2011-03-03 21:48:50 +0000 |
commit | 9aff6b75669f4e04aa05dab0ba8a554c199f270d (patch) | |
tree | e99dde3cd0e76b29800eee656e4e891636a50ba8 | |
parent | 496e4ced8e432675763c019790713eab351310e2 (diff) |
Prevent division-by-zero when scaling down to the screen resolution. Make
the WSMOUSEIO_SCALIBCOORDS fail with EINVAL if the settings would cause a
division-by-zero.
ok deraadt@
-rw-r--r-- | sys/arch/zaurus/dev/zts.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/uhts.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/uts.c | 8 |
3 files changed, 18 insertions, 6 deletions
diff --git a/sys/arch/zaurus/dev/zts.c b/sys/arch/zaurus/dev/zts.c index 10b98f37bed..938a586ae14 100644 --- a/sys/arch/zaurus/dev/zts.c +++ b/sys/arch/zaurus/dev/zts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zts.c,v 1.14 2010/09/07 16:21:41 deraadt Exp $ */ +/* $OpenBSD: zts.c,v 1.15 2011/03/03 21:48:49 kettenis Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> * @@ -511,7 +511,9 @@ zts_irq(void *v) if (down) { zts_avgpos(&tp); - if (!sc->sc_rawmode) { + if (!sc->sc_rawmode && + (sc->sc_tsscale.maxx - sc->sc_tsscale.minx) != 0 && + (sc->sc_tsscale.maxy - sc->sc_tsscale.miny) != 0) { /* Scale down to the screen resolution. */ tp.x = ((tp.x - sc->sc_tsscale.minx) * sc->sc_tsscale.resx) / @@ -571,6 +573,8 @@ zts_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) wsmc->resx >= 0 && wsmc->resy >= 0 && wsmc->minx < 32768 && wsmc->maxx < 32768 && wsmc->miny < 32768 && wsmc->maxy < 32768 && + (wsmc->maxx - wsmc->minx) != 0 && + (wsmc->maxy - wsmc->miny) != 0 && wsmc->resx < 32768 && wsmc->resy < 32768 && wsmc->swapxy >= 0 && wsmc->swapxy <= 1 && wsmc->samplelen >= 0 && wsmc->samplelen <= 1)) diff --git a/sys/dev/usb/uhts.c b/sys/dev/usb/uhts.c index b46d7a4d17d..318ac3a4448 100644 --- a/sys/dev/usb/uhts.c +++ b/sys/dev/usb/uhts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhts.c,v 1.1 2009/12/09 21:27:19 matthieu Exp $ */ +/* $OpenBSD: uhts.c,v 1.2 2011/03/03 21:48:49 kettenis Exp $ */ /* * Copyright (c) 2009 Matthieu Herrb <matthieu@herrb.eu> * Copyright (c) 2007 Robert Nagy <robert@openbsd.org> @@ -291,7 +291,9 @@ uhts_intr(struct uhidev *addr, void *buf, u_int len) tp.x = x; tp.y = y; } - if (!sc->sc_rawmode) { + if (!sc->sc_rawmode && + (sc->sc_tsscale.maxx - sc->sc_tsscale.minx) != 0 && + (sc->sc_tsscale.maxy - sc->sc_tsscale.miny) != 0) { /* Scale down to the screen resolution. */ tp.x = ((tp.x - sc->sc_tsscale.minx) * sc->sc_tsscale.resx) / @@ -374,6 +376,8 @@ uhts_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) wsmc->resx >= 0 && wsmc->resy >= 0 && wsmc->minx < 32768 && wsmc->maxx < 32768 && wsmc->miny < 32768 && wsmc->maxy < 32768 && + (wsmc->maxx - wsmc->minx) != 0 && + (wsmc->maxy - wsmc->miny) != 0 && wsmc->resx < 32768 && wsmc->resy < 32768 && wsmc->swapxy >= 0 && wsmc->swapxy <= 1 && wsmc->samplelen >= 0 && wsmc->samplelen <= 1)) diff --git a/sys/dev/usb/uts.c b/sys/dev/usb/uts.c index 78b9424c5df..a626015ede3 100644 --- a/sys/dev/usb/uts.c +++ b/sys/dev/usb/uts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uts.c,v 1.28 2011/01/25 20:03:36 jakemsr Exp $ */ +/* $OpenBSD: uts.c,v 1.29 2011/03/03 21:48:49 kettenis Exp $ */ /* * Copyright (c) 2007 Robert Nagy <robert@openbsd.org> @@ -339,6 +339,8 @@ uts_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *l) wsmc->resx >= 0 && wsmc->resy >= 0 && wsmc->minx < 32768 && wsmc->maxx < 32768 && wsmc->miny < 32768 && wsmc->maxy < 32768 && + (wsmc->maxx - wsmc->minx) != 0 && + (wsmc->maxy - wsmc->miny) != 0 && wsmc->resx < 32768 && wsmc->resy < 32768 && wsmc->swapxy >= 0 && wsmc->swapxy <= 1 && wsmc->samplelen >= 0 && wsmc->samplelen <= 1)) @@ -430,7 +432,9 @@ uts_get_pos(usbd_private_handle addr, struct uts_pos *tp) tp->x = x; tp->y = y; } - if (!sc->sc_rawmode) { + if (!sc->sc_rawmode && + (sc->sc_tsscale.maxx - sc->sc_tsscale.minx) != 0 && + (sc->sc_tsscale.maxy - sc->sc_tsscale.miny) != 0) { /* Scale down to the screen resolution. */ tp->x = ((tp->x - sc->sc_tsscale.minx) * sc->sc_tsscale.resx) / |