From 7778389b1a059ce9a3992985f7ea1bfa946d17a9 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Wed, 12 Feb 2020 09:32:04 -0800 Subject: [PATCH] Fixed User HAL dump. It was not validating the input before storing the response form lshal, which would crash it later. Test: adb shell lshal debug android.hardware.automotive.vehicle@2.0::IVehicle/default --set 299896583 a 2 Bug: 146207078 Change-Id: I49a38041e2881224c61e3c645db7c9103d024040 --- .../default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp index 63ad93c375..7f90914302 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleConnector.cpp @@ -311,6 +311,11 @@ StatusCode EmulatedVehicleServer::onSetInitialUserInfo(const VehiclePropValue& v // (even when explicitly calling setprop log.tag. As this class should be using ALOG instead of // LOG, it's not worth investigating why... + if (value.value.int32Values.size() == 0) { + LOG(ERROR) << "set(INITIAL_USER_INFO): no int32values, ignoring it: " << toString(value); + return StatusCode::INVALID_ARG; + } + if (value.areaId != 0) { LOG(INFO) << "set(INITIAL_USER_INFO) called from lshal; storing it: " << toString(value); mInitialUserResponseFromCmd.reset(new VehiclePropValue(value)); @@ -318,10 +323,6 @@ StatusCode EmulatedVehicleServer::onSetInitialUserInfo(const VehiclePropValue& v } LOG(INFO) << "set(INITIAL_USER_INFO) called from Android: " << toString(value); - if (value.value.int32Values.size() == 0) { - LOG(ERROR) << "invalid request (no requestId): " << toString(value); - return StatusCode::INVALID_ARG; - } int32_t requestId = value.value.int32Values[0]; // Create the update property and set common values