Commit 8289dc75 authored by Johann Fischer's avatar Johann Fischer Committed by David Leach
Browse files

usb: dfu: check requested length (wLength) during DFU_UPLOAD



During DFU_UPLOAD, the host could requests more data
as stated in wTransferSize. Limit upload length to the
size of the request buffer (USB_REQUEST_BUFFER_SIZE).

Signed-off-by: default avatarJohann Fischer <j.fischer@phytec.de>
Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent 8fa136d9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -509,6 +509,15 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
				len = pSetup->wLength;
			}

			if (len > USB_DFU_MAX_XFER_SIZE) {
				/*
				 * The host could requests more data as stated
				 * in wTransferSize. Limit upload length to the
				 * size of the request-buffer.
				 */
				len = USB_DFU_MAX_XFER_SIZE;
			}

			if (len) {
				const struct flash_area *fa;