Skip to content

Commit

Permalink
USB: Fix possible buffer overflow in webcam
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jan 27, 2024
1 parent e5bb405 commit c5a2844
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pcsx2/USB/usb-eyetoy/usb-eyetoy-webcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ namespace usb_eyetoy
static void webcam_handle_data_eyetoy(USBDevice* dev, USBPacket* p)
{
EYETOYState* s = USB_CONTAINER_OF(dev, EYETOYState, dev);
static const int max_ep_size = 896;
static const unsigned int max_ep_size = 896;
uint8_t devep = p->ep->nr;

if (!s->hw_camera_running)
Expand Down Expand Up @@ -326,7 +326,7 @@ namespace usb_eyetoy
s->frame_step = 0;
}

usb_packet_copy(p, data, max_ep_size);
usb_packet_copy(p, data, std::min(max_ep_size, p->buffer_size));
}
else if (devep == 2)
{
Expand All @@ -346,7 +346,7 @@ namespace usb_eyetoy
static void webcam_handle_data_ov511p(USBDevice* dev, USBPacket* p)
{
EYETOYState* s = USB_CONTAINER_OF(dev, EYETOYState, dev);
static const int max_ep_size = 960; // 961
static const unsigned int max_ep_size = 960; // 961
uint8_t devep = p->ep->nr;

if (!s->hw_camera_running)
Expand Down Expand Up @@ -397,7 +397,7 @@ namespace usb_eyetoy
s->frame_step = 0;
}

usb_packet_copy(p, data, max_ep_size);
usb_packet_copy(p, data, std::min(max_ep_size, p->buffer_size));
}
break;
case USB_TOKEN_OUT:
Expand Down

0 comments on commit c5a2844

Please sign in to comment.