diff options
author | Joshua Stein <jcs@cvs.openbsd.org> | 2016-01-13 15:10:36 +0000 |
---|---|---|
committer | Joshua Stein <jcs@cvs.openbsd.org> | 2016-01-13 15:10:36 +0000 |
commit | 3bf9f9bcdd8d2d15f2c5d802803a82a6abc652d2 (patch) | |
tree | d85189e6f03ae8dee415d8815bf3c96ecc7f1d38 /sys/dev/i2c | |
parent | 1d5f7cad504c441dd37813d2e6e503d1b89aa2bd (diff) |
fix hid packet length calculation
noticed by jsg
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r-- | sys/dev/i2c/ihidev.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c index a65e372762c..5ab2ffefdd8 100644 --- a/sys/dev/i2c/ihidev.c +++ b/sys/dev/i2c/ihidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ihidev.c,v 1.3 2016/01/13 10:25:31 kettenis Exp $ */ +/* $OpenBSD: ihidev.c,v 1.4 2016/01/13 15:10:35 jcs Exp $ */ /* * HID-over-i2c driver * @@ -418,7 +418,6 @@ ihidev_intr(void *arg) struct ihidev_softc *sc = arg; struct ihidev *scd; size_t size, psize; - u_int32_t cc; int res, i; u_char *p; u_int rep = 0; @@ -456,8 +455,9 @@ ihidev_intr(void *arg) /* report id is 3rd byte */ p = sc->sc_ibuf + 2; + psize -= 2; if (sc->sc_nrepid != 1) - rep = *p++, cc--; + rep = *p++; psize--; if (rep >= sc->sc_nrepid) { printf("%s: %s: bad repid %d\n", sc->sc_dev.dv_xname, __func__, @@ -469,7 +469,7 @@ ihidev_intr(void *arg) if (scd == NULL || !(scd->sc_state & IHIDEV_OPEN)) return (1); - scd->sc_intr(scd, p, cc); + scd->sc_intr(scd, p, psize); return (1); } |