summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrppicomidi <[email protected]>2025-03-20 06:27:23 -0700
committerrppicomidi <[email protected]>2025-03-20 06:27:23 -0700
commit4b46493cb4f8699c95e01783eee5cf90ca7810e2 (patch)
tree65eed401ce1a2da7009a61e31a515a5b1dafc71d
parentc2924c51fc9bf0074663cafabf4399ca9d673750 (diff)
Fix #3033: Increase array bounds and test for overflow
-rw-r--r--src/class/midi/midi_host.c3
-rw-r--r--src/class/midi/midi_host.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/class/midi/midi_host.c b/src/class/midi/midi_host.c
index cfea0c080..68e46aca3 100644
--- a/src/class/midi/midi_host.c
+++ b/src/class/midi/midi_host.c
@@ -254,7 +254,8 @@ bool midih_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *d
TU_LOG_DRV(" Jack %s %s descriptor \r\n",
tu_desc_subtype(p_desc) == MIDI_CS_INTERFACE_IN_JACK ? "IN" : "OUT",
p_desc[3] == MIDI_JACK_EXTERNAL ? "External" : "Embedded");
- desc_cb.desc_jack[desc_cb.jack_num++] = p_desc;
+ if (desc_cb.jack_num < TU_ARRAY_SIZE(desc_cb.desc_jack))
+ desc_cb.desc_jack[desc_cb.jack_num++] = p_desc;
break;
}
diff --git a/src/class/midi/midi_host.h b/src/class/midi/midi_host.h
index 67df25a82..06554a03d 100644
--- a/src/class/midi/midi_host.h
+++ b/src/class/midi/midi_host.h
@@ -69,7 +69,7 @@ typedef struct {
const tusb_desc_endpoint_t* desc_epout; // endpoint OUT descriptor, CS_ENDPOINT is right after
uint8_t jack_num;
- const uint8_t* desc_jack[16]; // list of jack descriptors (embedded + external)
+ const uint8_t* desc_jack[32]; // list of jack descriptors (embedded + external)
} tuh_midi_descriptor_cb_t;
typedef struct {