summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-12-15 11:51:17 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-12-15 11:51:17 +0000
commit6da5df470099fc55f20b03ef364af730e7be4ffe (patch)
tree4ee90fc8ba60a8652fe1d761d5a84ee38374bd48
parent1d0272a600c7e64f641c3193eabd41f467c2d6ff (diff)
downloadsrc-test2-6da5df470099fc55f20b03ef364af730e7be4ffe.tar.gz
src-test2-6da5df470099fc55f20b03ef364af730e7be4ffe.zip
Notes
-rw-r--r--sys/dev/usb/usb_parse.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/dev/usb/usb_parse.c b/sys/dev/usb/usb_parse.c
index 5cace00fadc7..15bd1c967044 100644
--- a/sys/dev/usb/usb_parse.c
+++ b/sys/dev/usb/usb_parse.c
@@ -2,7 +2,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2008-2020 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -141,8 +141,20 @@ usb_idesc_foreach(struct usb_config_descriptor *cd,
break;
if ((id->bDescriptorType == UDESC_INTERFACE) &&
(id->bLength >= sizeof(*id))) {
- if (ps->iface_no_last == id->bInterfaceNumber)
+ if (ps->iface_no_last == id->bInterfaceNumber) {
+ /*
+ * Don't allow more than 256 alternate
+ * settings to avoid overflowing the
+ * alternate index which is a 8-bit
+ * variable.
+ */
+ if (ps->iface_index_alt == 255) {
+ DPRINTF("Interface(%u) has more than 256 alternate settings\n",
+ id->bInterfaceNumber);
+ continue;
+ }
new_iface = 0;
+ }
ps->iface_no_last = id->bInterfaceNumber;
break;
}