summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-03-13 11:35:47 +0000
committerriastradh <riastradh@NetBSD.org>2022-03-13 11:35:47 +0000
commit299cc587a4c8a8db2614ae0f887905b30c6728bb (patch)
tree46d0ec7f03fe6b0837d27010046b55a35702847c /sys/dev
parentc99728e8e8359c6b046a7fbd4f2de946ac97ec65 (diff)
hid: Avoid arithmetic overflow by rearranging inequalities.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/hid/hid.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/hid/hid.c b/sys/dev/hid/hid.c
index 8461aa5a8f4..a157dea69f2 100644
--- a/sys/dev/hid/hid.c
+++ b/sys/dev/hid/hid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.c,v 1.4 2020/01/01 09:40:17 maxv Exp $ */
+/* $NetBSD: hid.c,v 1.5 2022/03/13 11:35:47 riastradh Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.4 2020/01/01 09:40:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.5 2022/03/13 11:35:47 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -150,7 +150,7 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
for (;;) {
p = s->p;
- if (p + 1 > s->end)
+ if (s->end - p < 1)
return 0;
bSize = *p++;
@@ -172,7 +172,7 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
}
data = p;
- if (p + bSize > s->end)
+ if (bSize > s->end - p)
return 0;
p += bSize;