Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Improve the check, to prevent more surprises.



details:   https://anonhg.NetBSD.org/src/rev/8635dddf8f9a
branches:  trunk
changeset: 744897:8635dddf8f9a
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Feb 16 09:53:54 2020 +0000

description:
Improve the check, to prevent more surprises.

diffstat:

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

diffs (29 lines):

diff -r 5a439ffd7649 -r 8635dddf8f9a sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c  Sun Feb 16 09:40:35 2020 +0000
+++ b/sys/dev/usb/usbdi_util.c  Sun Feb 16 09:53:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi_util.c,v 1.80 2020/02/16 09:40:35 maxv Exp $     */
+/*     $NetBSD: usbdi_util.c,v 1.81 2020/02/16 09:53:54 maxv Exp $     */
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.80 2020/02/16 09:40:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.81 2020/02/16 09:53:54 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -739,8 +739,8 @@
                return NULL;
        }
        desc = (const usb_descriptor_t *)iter->cur;
-       if (desc->bLength == 0) {
-               printf("%s: descriptor length = 0\n", __func__);
+       if (desc->bLength < USB_DESCRIPTOR_SIZE) {
+               printf("%s: descriptor length too small\n", __func__);
                return NULL;
        }
        if (iter->cur + desc->bLength > iter->end) {



Home | Main Index | Thread Index | Old Index