tinyusb: Do not access string descriptor array out of boundaries

The previous version of esp_tinyusb (v1.0.0) always assumed 8 string descriptors.
In case the user passed a smaller array of descriptors,
esp_tinyusb accessed memory outside of the array.
This is fixed esp_tinyusb v1.1.0 by 046cc4b02f
This commit is contained in:
Tomas Rezucha 2023-02-23 11:16:37 +01:00
parent 0d97eeb7a5
commit 2b5caf34b7
6 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,4 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_tinyusb: "^1"
espressif/esp_tinyusb: "^1.1"
idf: "^5.0"

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -167,6 +167,7 @@ void app_main(void)
const tinyusb_config_t tusb_cfg = {
.device_descriptor = NULL,
.string_descriptor = hid_string_descriptor,
.string_descriptor_count = sizeof(hid_string_descriptor) / sizeof(hid_string_descriptor[0]),
.external_phy = false,
.configuration_descriptor = hid_configuration_descriptor,
};

View File

@ -1,4 +1,4 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_tinyusb: "^1"
espressif/esp_tinyusb: "^1.1"
idf: "^5.0"

View File

@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: MIT
*
* SPDX-FileContributor: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2022-2023 Espressif Systems (Shanghai) CO LTD
*/
#include <stdlib.h>
@ -137,6 +137,7 @@ void app_main(void)
tinyusb_config_t const tusb_cfg = {
.device_descriptor = NULL, // If device_descriptor is NULL, tinyusb_driver_install() will use Kconfig
.string_descriptor = s_str_desc,
.string_descriptor_count = sizeof(s_str_desc) / sizeof(s_str_desc[0]),
.external_phy = false,
.configuration_descriptor = s_midi_cfg_desc,
};

View File

@ -1,4 +1,4 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_tinyusb: "^1"
espressif/esp_tinyusb: "^1.1"
idf: "^5.0"

View File

@ -482,6 +482,7 @@ void app_main(void)
const tinyusb_config_t tusb_cfg = {
.device_descriptor = &descriptor_config,
.string_descriptor = string_desc_arr,
.string_descriptor_count = sizeof(string_desc_arr) / sizeof(string_desc_arr[0]),
.external_phy = false,
.configuration_descriptor = desc_configuration,
.self_powered = true,