Skip to content

Commit

Permalink
fix buffer overflow bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonlock2 committed Dec 6, 2023
1 parent a1ae2a3 commit 9dfc5fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/portable/wch/ch32v20x/dcd_usbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ static void update_in(uint8_t rhport, uint8_t ep, bool force) {
static void update_out(uint8_t rhport, uint8_t ep, size_t rx_len) {
struct usb_xfer *xfer = &data.xfer[ep][TUSB_DIR_OUT];
if (xfer->valid) {
size_t len = TU_MIN(xfer->len, rx_len);
memcpy(xfer->buffer, data.buffer[ep][TUSB_DIR_OUT], rx_len);
size_t len = TU_MIN(xfer->max_size, TU_MIN(xfer->len, rx_len));
memcpy(xfer->buffer, data.buffer[ep][TUSB_DIR_OUT], len);
xfer->buffer += len;
xfer->len -= len;
xfer->processed_len += len;
Expand Down

0 comments on commit 9dfc5fe

Please sign in to comment.