diff options
| author | Nathaniel Brough <[email protected]> | 2023-01-13 13:37:55 -0800 |
|---|---|---|
| committer | Nathaniel Brough <[email protected]> | 2023-01-13 15:20:32 -0800 |
| commit | 2e47210c1af88b88b6f2d92fe2b6d08117041363 (patch) | |
| tree | 7215930f85dd6fcdb0e92a896f3231b3cc57fe2f /src/device/usbd_control.c | |
| parent | 8775d55adc7c9b0812b7d593b24518c046dd3d82 (diff) | |
fix: Replace device calls to memcpy with tu_memcpy_s
Introduces a new function tu_memcpy_s, which is effectively
a backport of memcpy_s. The change also refactors calls
to memcpy over to the more secure tu_memcpy_s.
Diffstat (limited to 'src/device/usbd_control.c')
| -rw-r--r-- | src/device/usbd_control.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 0995ef669..ce4ddab66 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -93,7 +93,9 @@ static bool _data_stage_xact(uint8_t rhport) if ( _ctrl_xfer.request.bmRequestType_bit.direction == TUSB_DIR_IN ) { ep_addr = EDPT_CTRL_IN; - if ( xact_len ) memcpy(_usbd_ctrl_buf, _ctrl_xfer.buffer, xact_len); + if ( xact_len ) { + TU_VERIFY(tu_memcpy_s(_usbd_ctrl_buf, CFG_TUD_ENDPOINT0_SIZE, _ctrl_xfer.buffer, xact_len)==0); + } } return usbd_edpt_xfer(rhport, ep_addr, xact_len ? _usbd_ctrl_buf : NULL, xact_len); |
