Guard max packet size from too big values

This commit is contained in:
Stefan Rueger
2026-06-17 22:34:05 +01:00
parent c96efc99cf
commit d2dab63572
2 changed files with 5 additions and 1 deletions

View File

@@ -213,7 +213,7 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
}
}
if(fd->usb.max_xfer > USBDEV_MAX_XFER_3) {
pmsg_error("unexpected max size %d, reducing to %d\n", fd->usb.max_xfer, USBDEV_MAX_XFER_3);
pmsg_error("reducing too big max packet size %d to %d\n", fd->usb.max_xfer, USBDEV_MAX_XFER_3);
fd->usb.max_xfer = USBDEV_MAX_XFER_3;
}

View File

@@ -213,6 +213,10 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
}
}
}
if(fd->usb.max_xfer > USBDEV_MAX_XFER_3) {
pmsg_error("reducing too big max packet size %d to %d\n", fd->usb.max_xfer, USBDEV_MAX_XFER_3);
fd->usb.max_xfer = USBDEV_MAX_XFER_3;
}
if(usehid && usb_control_msg(udev, 0x21, 0x0a /* SET_IDLE */ , 0, 0, NULL, 0, 100) < 0)
pmsg_warning("SET_IDLE failed\n");
return 0;