summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorReinhard Panhuber <[email protected]>2020-06-20 11:10:35 +0200
committerReinhard Panhuber <[email protected]>2020-06-20 11:10:35 +0200
commit28505cf03e31b5e7f0f9dddd8073975d305daa5d (patch)
tree15b9f98ea4bec3f5824517fbac7db3e7b42065b5 /src/class
parent948728b82e785f52c4ee3b7bb290cd90526ac629 (diff)
parentada82b840f642681f8012cb2a46aa7577393dd30 (diff)
Merge branch 'master' into uac2
Conflicts: src/device/usbd.c
Diffstat (limited to 'src/class')
-rw-r--r--src/class/hid/hid_device.c4
-rw-r--r--src/class/msc/msc_device.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index 2a20bc173..526394d4a 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -194,7 +194,9 @@ uint16_t hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint1
p_hid->boot_mode = false; // default mode is REPORT
p_hid->itf_num = desc_itf->bInterfaceNumber;
- memcpy(&p_hid->report_desc_len, &(p_hid->hid_descriptor->wReportLength), 2);
+
+ // Use offsetof to avoid pointer to the odd/misaligned address
+ memcpy(&p_hid->report_desc_len, (uint8_t*) p_hid->hid_descriptor + offsetof(tusb_hid_descriptor_hid_t, wReportLength), 2);
// Prepare for output endpoint
if (p_hid->ep_out)
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index b038d00f7..3ddcd4e49 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -80,7 +80,8 @@ static inline uint32_t rdwr10_get_lba(uint8_t const command[])
// copy first to prevent mis-aligned access
uint32_t lba;
- memcpy(&lba, &p_rdwr10->lba, 4);
+ // use offsetof to avoid pointer to the odd/misaligned address
+ memcpy(&lba, (uint8_t*) p_rdwr10 + offsetof(scsi_write10_t, lba), 4);
// lba is in Big Endian format
return tu_ntohl(lba);
@@ -93,7 +94,8 @@ static inline uint16_t rdwr10_get_blockcount(uint8_t const command[])
// copy first to prevent mis-aligned access
uint16_t block_count;
- memcpy(&block_count, &p_rdwr10->block_count, 2);
+ // use offsetof to avoid pointer to the odd/misaligned address
+ memcpy(&block_count, (uint8_t*) p_rdwr10 + offsetof(scsi_write10_t, block_count), 2);
return tu_ntohs(block_count);
}