1- /* $Id: VUSBUrb.cpp 112702 2026-01-26 16:00:13Z michal.necasek@oracle.com $ */
1+ /* $Id: VUSBUrb.cpp 114696 2026-07-14 11:50:33Z michal.necasek@oracle.com $ */
22/* * @file
33 * Virtual USB - URBs.
44 */
@@ -976,11 +976,15 @@ static int vusbUrbSubmitCtrl(PVUSBURB pUrb)
976976 LogFlow ((" %s: vusbUrbSubmitCtrl: Adjusting DATA request: %d -> %d\n " , pUrb->pszDesc , pUrb->cbData , cbLeft));
977977 pUrb->cbData = cbLeft >= 0 ? (uint32_t )cbLeft : 0 ;
978978 }
979- /* In the host -> direction it's undefined what happens if the host provides
980- more data than what wLength inidicated. However, in 2007, iPhone detection
981- via iTunes would issue wLength=0 but provide a data URB which we needed to
982- pass on to the device anyway, so we'll just quietly adjust wLength if it's
983- zero and get on with the work.
979+ /* In the host -> device direction it's "undefined" what happens if the host
980+ provides more data than what wLength indicated. The USB specification is
981+ clear that the data phase length must match wLength, but this does not appear
982+ to have been enforced. The xHCI specification explicitly says that that the
983+ spec may need to be violated for compatibility with some devices.
984+ The Apple Mobile Device support version 1.1.1.1 (shipped with iTunes 7.4.3)
985+ is one known offender; as soon as an iPhone is plugged in, the guest issues
986+ a control transfer with wLength=0 but an 8-byte data buffer. We'll just quietly
987+ adjust wLength if it's zero and get on with life.
984988
985989 What confuses me (bird) here, though, is that we've already sent the SETUP
986990 URB to the device when we received it, and all we end up doing is an
@@ -992,7 +996,7 @@ static int vusbUrbSubmitCtrl(PVUSBURB pUrb)
992996 P.S. We used to have a very strange (pUrb->cbData % pSetup->wLength) == 0
993997 thing too that joined the pUrb->cbData adjusting above. */
994998 else if ( pSetup->wLength == 0
995- && pUrb->cbData <= pExtra->cbMax )
999+ && pUrb->cbData <= ( pExtra->cbMax - sizeof ( VUSBSETUP )) )
9961000 {
9971001 Log ((" %s: vusbUrbSubmitCtrl: pAdjusting wLength: %u -> %u (iPhone hack)\n " ,
9981002 pUrb->pszDesc , pSetup->wLength , pUrb->cbData ));
0 commit comments