diff options
| author | 2011-03-03 21:48:49 +0000 | |
|---|---|---|
| committer | 2011-03-03 21:48:49 +0000 | |
| commit | 763417117b3fbf815539427111006ae3005c1a0b (patch) | |
| tree | 4bea416ee39e947b642aee36b629c218ed82bd3b /sys/dev/usb/uts.c | |
| parent | Crank MAXDSIZ up to 2G on macppc and socppc. (diff) | |
| download | wireguard-openbsd-763417117b3fbf815539427111006ae3005c1a0b.tar.xz wireguard-openbsd-763417117b3fbf815539427111006ae3005c1a0b.zip | |
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@
Diffstat (limited to 'sys/dev/usb/uts.c')
| -rw-r--r-- | sys/dev/usb/uts.c | 8 |
1 files changed, 6 insertions, 2 deletions
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) / |
