From d2dab6357293882ccfed82241118e90ded8191e1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 17 Jun 2026 22:34:05 +0100 Subject: [PATCH] Guard max packet size from too big values --- src/usb_hidapi.c | 2 +- src/usb_libusb.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/usb_hidapi.c b/src/usb_hidapi.c index d3a019af..beda975b 100644 --- a/src/usb_hidapi.c +++ b/src/usb_hidapi.c @@ -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; } diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 05ca8406..70c58fd8 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -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;