Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/hid hid: Avoid arithmetic overflow by rearranging in...



details:   https://anonhg.NetBSD.org/src/rev/eae7618824f2
branches:  trunk
changeset: 363473:eae7618824f2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Mar 13 11:35:47 2022 +0000

description:
hid: Avoid arithmetic overflow by rearranging inequalities.

diffstat:

 sys/dev/hid/hid.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r b01ed1f7fb28 -r eae7618824f2 sys/dev/hid/hid.c
--- a/sys/dev/hid/hid.c Sun Mar 13 11:30:12 2022 +0000
+++ b/sys/dev/hid/hid.c Sun Mar 13 11:35:47 2022 +0000
@@ -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 @@
        for (;;) {
                p = s->p;
 
-               if (p + 1 > s->end)
+               if (s->end - p < 1)
                        return 0;
                bSize = *p++;
 
@@ -172,7 +172,7 @@
                }
 
                data = p;
-               if (p + bSize > s->end)
+               if (bSize > s->end - p)
                        return 0;
                p += bSize;
 



Home | Main Index | Thread Index | Old Index