summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2023-02-27 10:22:53 +0700
committerGitHub <[email protected]>2023-02-27 10:22:53 +0700
commit65ac519715ea0ecace08b183f2d8730d0450affd (patch)
tree11c48c98d3afea290e460deed624a07bac0607e7 /src/device
parent73afca14eb589af84e932fdafbeeea8f8db1e771 (diff)
parente34aeb5cf69315d2d7711f0a1d040a28492d026d (diff)
Merge pull request #1852 from silvergasp/mem_s
fix: Replace device calls to memcpy with tu_memcpy_s
Diffstat (limited to 'src/device')
-rw-r--r--src/device/dcd.h2
-rw-r--r--src/device/usbd_control.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index c1780f656..3a7e6c5df 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -193,7 +193,7 @@ TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_reset (uint8_t rhport, t
TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr)
{
dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SETUP_RECEIVED };
- memcpy(&event.setup_received, setup, 8);
+ memcpy(&event.setup_received, setup, sizeof(tusb_control_request_t));
dcd_event_handler(&event, in_isr);
}
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index e709658b9..ea8eef285 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(0 == tu_memcpy_s(_usbd_ctrl_buf, CFG_TUD_ENDPOINT0_SIZE, _ctrl_xfer.buffer, xact_len));
+ }
}
return usbd_edpt_xfer(rhport, ep_addr, xact_len ? _usbd_ctrl_buf : NULL, xact_len);