Skip to content

Commit 7641060

Browse files
committed
Merge branch 'master' into zephyr-support
2 parents 8c7998b + 37e6f49 commit 7641060

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

examples/device/cdc_msc/src/msc_disk.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
190190
(void) lun;
191191

192192
// out of ramdisk
193-
if ( lba >= DISK_BLOCK_NUM ) return -1;
193+
if ( lba >= DISK_BLOCK_NUM ) {
194+
return -1;
195+
}
196+
197+
// Check for overflow of offset + bufsize
198+
if ( offset + bufsize > DISK_BLOCK_SIZE ) {
199+
return -1;
200+
}
194201

195202
uint8_t const* addr = msc_disk[lba] + offset;
196203
memcpy(buffer, addr, bufsize);

examples/device/cdc_msc_freertos/src/msc_disk.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
190190
(void) lun;
191191

192192
// out of ramdisk
193-
if ( lba >= DISK_BLOCK_NUM ) return -1;
193+
if ( lba >= DISK_BLOCK_NUM ) {
194+
return -1;
195+
}
196+
197+
// Check for overflow of offset + bufsize
198+
if ( offset + bufsize > DISK_BLOCK_SIZE ) {
199+
return -1;
200+
}
194201

195202
uint8_t const* addr = msc_disk[lba] + offset;
196203
memcpy(buffer, addr, bufsize);

src/class/net/ncm_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
857857
// - if there is a free receive buffer, initiate reception
858858
if (!recv_validate_datagram(ncm_interface.recv_tinyusb_ntb, xferred_bytes)) {
859859
// verification failed: ignore NTB and return it to free
860-
TU_LOG_DRV("(EE) VALIDATION FAILED. WHAT CAN WE DO IN THIS CASE?\n");
860+
TU_LOG_DRV("Invalid datatagram. Ignoring NTB\n");
861+
recv_put_ntb_into_free_list(ncm_interface.recv_tinyusb_ntb);
861862
} else {
862863
// packet ok -> put it into ready list
863864
recv_put_ntb_into_ready_list(ncm_interface.recv_tinyusb_ntb);

0 commit comments

Comments
 (0)