Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb usbdi(9): Make usb_desc_iter_next_interface reje...
details: https://anonhg.NetBSD.org/src/rev/a4bade64b46a
branches: trunk
changeset: 365284:a4bade64b46a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Apr 17 13:16:52 2022 +0000
description:
usbdi(9): Make usb_desc_iter_next_interface reject truncated descs.
Currently callers have to check whether the descriptor is truncated,
which is willy.
diffstat:
sys/dev/usb/usbdi_util.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (31 lines):
diff -r 7c49c37fa795 -r a4bade64b46a sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c Sun Apr 17 13:16:43 2022 +0000
+++ b/sys/dev/usb/usbdi_util.c Sun Apr 17 13:16:52 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.c,v 1.86 2022/04/17 13:16:43 riastradh Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.87 2022/04/17 13:16:52 riastradh 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.86 2022/04/17 13:16:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.87 2022/04/17 13:16:52 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -769,7 +769,11 @@
usb_desc_iter_next(iter);
}
- return (const usb_interface_descriptor_t *)usb_desc_iter_next(iter);
+ if ((desc = usb_desc_iter_next(iter)) == NULL ||
+ desc->bLength < sizeof(usb_interface_descriptor_t))
+ return NULL;
+ KASSERT(desc->bDescriptorType == UDESC_INTERFACE);
+ return (const usb_interface_descriptor_t *)desc;
}
/*
Home |
Main Index |
Thread Index |
Old Index