diff options
author | Josh Gao <jmgao@google.com> | 2019-05-15 18:03:29 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2019-05-17 18:34:23 -0700 |
commit | 12807c701240a42a2c3179b556a0a42bc0fc2de0 (patch) | |
tree | 831117782a9cb7445f61792a951d226bef578baf | |
parent | 9da358d6d3d8b12e27b45c1581d0c2ad978f1f83 (diff) | |
download | system_core-12807c701240a42a2c3179b556a0a42bc0fc2de0.tar.gz system_core-12807c701240a42a2c3179b556a0a42bc0fc2de0.tar.bz2 system_core-12807c701240a42a2c3179b556a0a42bc0fc2de0.zip |
adbd: read, print, and ignore USB control transfers.
It seems like we're blowing up when receiving a control transfer that's
intended for Android Auto, because we're not expecting to get the data
for the control transfer in a subsequent read.
Bug: http://b/131867920
Test: none
Change-Id: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
-rw-r--r-- | adb/daemon/usb.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 565a3647e..da04db10b 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -364,6 +364,33 @@ struct UsbFfsConnection : public Connection { bound = false; running = false; break; + + case FUNCTIONFS_SETUP: { + LOG(INFO) << "received FUNCTIONFS_SETUP control transfer: bRequestType = " + << static_cast<int>(event.u.setup.bRequestType) + << ", bRequest = " << static_cast<int>(event.u.setup.bRequest) + << ", wValue = " << static_cast<int>(event.u.setup.wValue) + << ", wIndex = " << static_cast<int>(event.u.setup.wIndex) + << ", wLength = " << static_cast<int>(event.u.setup.wLength); + + if ((event.u.setup.bRequestType & USB_DIR_IN)) { + LOG(WARNING) << "received a device-to-host control transfer, ignoring"; + } else { + std::string buf; + buf.resize(event.u.setup.wLength + 1); + + ssize_t rc = adb_read(control_fd_.get(), buf.data(), buf.size()); + if (rc != event.u.setup.wLength) { + LOG(ERROR) + << "read " << rc + << " bytes when trying to read control request, expected " + << event.u.setup.wLength; + } + + LOG(INFO) << "control request contents: " << buf; + break; + } + } } } |