Skip to content

Commit

Permalink
Merge "Prevent null vector accessing in USB HAL" into qt-qpr1-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Puma Hsu authored and Android (Google) Code Review committed Oct 15, 2019
2 parents b5a7d31 + 9ef0398 commit 1089a51
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion usb/Usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ int32_t writeFile(const std::string &filename, const std::string &contents) {
Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *currentPortStatus_1_2) {
std::string enabled, status;

if (currentPortStatus_1_2 == NULL || currentPortStatus_1_2->size() == 0) {
ALOGE("currentPortStatus_1_2 is not available");
return Status::ERROR;
}

(*currentPortStatus_1_2)[0].supportedContaminantProtectionModes = 0;
(*currentPortStatus_1_2)[0].supportedContaminantProtectionModes |=
ContaminantProtectionMode::FORCE_SINK;
Expand Down Expand Up @@ -564,7 +569,8 @@ void queryVersionHelper(android::hardware::usb::V1_2::implementation::Usb *usb,
if (usb->mCallback_1_0 != NULL) {
if (callback_V1_2 != NULL) {
status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_2);
queryMoistureDetectionStatus(currentPortStatus_1_2);
if (status == Status::SUCCESS)
queryMoistureDetectionStatus(currentPortStatus_1_2);
} else if (callback_V1_1 != NULL) {
status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_1);
currentPortStatus_1_1.resize(currentPortStatus_1_2->size());
Expand Down

0 comments on commit 1089a51

Please sign in to comment.