Skip to content

Commit 602ca41

Browse files
facchinmpolldo
authored andcommitted
USBCDC: fix buffer overflow when sending more than 64 bytes
1 parent 0c5f6cf commit 602ca41

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cores/arduino/USB/USBCDC.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ static const uint8_t cdc_line_coding_default[7] = {0x80, 0x25, 0x00, 0x00, 0x00,
4040
#define CLS_DTR (1 << 0)
4141
#define CLS_RTS (1 << 1)
4242

43+
#if defined(MBED_CONF_TARGET_USB_SPEED) && (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
44+
#define CDC_MAX_PACKET_SIZE 512
45+
#else
4346
#define CDC_MAX_PACKET_SIZE 64
47+
#endif
4448

4549
class USBCDC::AsyncWrite: public AsyncOp {
4650
public:

cores/arduino/USB/USBCDC.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ class USBCDC: public internal::PluggableUSBModule{
207207

208208
OperationList<AsyncWrite> _tx_list;
209209
bool _tx_in_progress;
210-
uint8_t _tx_buffer[64];
210+
uint8_t _tx_buffer[512];
211211
uint8_t *_tx_buf;
212212
uint32_t _tx_size;
213213

214214
OperationList<AsyncRead> _rx_list;
215215
bool _rx_in_progress;
216-
uint8_t _rx_buffer[64];
216+
uint8_t _rx_buffer[512];
217217
uint8_t *_rx_buf;
218218
uint32_t _rx_size;
219219
};

0 commit comments

Comments
 (0)