diff options
author | 2019-04-08 17:50:45 +0000 | |
---|---|---|
committer | 2019-04-08 17:50:45 +0000 | |
commit | f6f15de36573cfadcbca60e959b5b9ab8d2eda9b (patch) | |
tree | b43cb6b6e9bb7c60fa44122c81d92a7c06529184 /sys/dev/i2c | |
parent | macro args and punctuation should be space spearated; (diff) | |
download | wireguard-openbsd-f6f15de36573cfadcbca60e959b5b9ab8d2eda9b.tar.xz wireguard-openbsd-f6f15de36573cfadcbca60e959b5b9ab8d2eda9b.zip |
change psize to a signed int to cope with it going negative since
the data read during polling may be junk
fixed with Petr Ročkai
ok deraadt, mpi, stsp
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r-- | sys/dev/i2c/ihidev.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c index b34f97a48f4..50670975742 100644 --- a/sys/dev/i2c/ihidev.c +++ b/sys/dev/i2c/ihidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ihidev.c,v 1.18 2018/09/20 01:19:56 jsg Exp $ */ +/* $OpenBSD: ihidev.c,v 1.19 2019/04/08 17:50:45 jcs Exp $ */ /* * HID-over-i2c driver * @@ -585,8 +585,7 @@ ihidev_intr(void *arg) { struct ihidev_softc *sc = arg; struct ihidev *scd; - u_int psize; - int res, i, fast = 0; + int psize, res, i, fast = 0; u_char *p; u_int rep = 0; @@ -605,7 +604,7 @@ ihidev_intr(void *arg) * than or equal to wMaxInputLength */ psize = sc->sc_ibuf[0] | sc->sc_ibuf[1] << 8; - if (!psize || psize > sc->sc_isize) { + if (psize <= 2 || psize > sc->sc_isize) { if (sc->sc_poll) { /* * TODO: all fingers are up, should we pass to hid |