From a552d1eb91c2728bd2bcc5ca2159626864d0ee17 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 10 Mar 2019 22:40:52 +0800 Subject: [PATCH] usb-dev: limit the size of outgoing packets Signed-off-by: Sean Cross --- sw/src/usb-dev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sw/src/usb-dev.c b/sw/src/usb-dev.c index 273204c..8ce565c 100644 --- a/sw/src/usb-dev.c +++ b/sw/src/usb-dev.c @@ -102,8 +102,9 @@ void usb_setup(struct usb_device *dev, const struct usb_setup_request *setup) } goto send; } + i++; } - printf("%s:%d couldn't find descriptor (%d / %d)\n", __FILE__, __LINE__, setup->wIndex, setup->wValue); + printf("%s:%d couldn't find descriptor %04x (%d / %d)\n", __FILE__, __LINE__, setup->wValue, setup->wIndex, setup->wValue); usb_err(dev, 0); return; @@ -236,7 +237,8 @@ void usb_setup(struct usb_device *dev, const struct usb_setup_request *setup) send: if (data && datalen) { - printf("%s:%d sending %d bytes from %08x\n", __FILE__, __LINE__, datalen, data); + if (datalen > setup->wLength) + datalen = setup->wLength; usb_send(dev, 0, data, datalen); } else