summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-26 21:06:27 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-26 21:06:27 +0000
commit50d9be7fd13a3f557a275afcaf2cc50a0a055aad (patch)
tree843f67655da4e6d1e81893377c45d36449daf1b9
parenta678f1f1171eec0ca830114fa262a0e90eba3558 (diff)
parent81061238c19d7ebabb453697a8c643324cf6c68e (diff)
downloadnative-50d9be7fd13a3f557a275afcaf2cc50a0a055aad.tar.gz
Snap for 8363780 from 81061238c19d7ebabb453697a8c643324cf6c68e to sc-qpr3-release
Change-Id: Ia99367d8e76f1ec7fb832dcd4fcdc09d360d95b8
-rw-r--r--cmds/installd/InstalldNativeService.cpp4
-rw-r--r--cmds/installd/tests/installd_service_test.cpp13
2 files changed, 17 insertions, 0 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 95d9377a89..b84be9b1e6 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -1766,6 +1766,10 @@ binder::Status InstalldNativeService::getAppSize(const std::optional<std::string
const std::vector<std::string>& codePaths, std::vector<int64_t>* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
CHECK_ARGUMENT_UUID(uuid);
+ if (packageNames.size() != ceDataInodes.size()) {
+ return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
+ "packageNames/ceDataInodes size mismatch.");
+ }
for (const auto& packageName : packageNames) {
CHECK_ARGUMENT_PACKAGE_NAME(packageName);
}
diff --git a/cmds/installd/tests/installd_service_test.cpp b/cmds/installd/tests/installd_service_test.cpp
index 36574974d9..b910ac103b 100644
--- a/cmds/installd/tests/installd_service_test.cpp
+++ b/cmds/installd/tests/installd_service_test.cpp
@@ -322,6 +322,19 @@ TEST_F(ServiceTest, GetAppSize) {
system(removeCommand.c_str());
}
}
+TEST_F(ServiceTest, GetAppSizeWrongSizes) {
+ int32_t externalStorageAppId = -1;
+ std::vector<int64_t> externalStorageSize;
+
+ std::vector<std::string> codePaths;
+ std::vector<std::string> packageNames = {"package1", "package2"};
+ std::vector<int64_t> ceDataInodes = {0};
+
+ EXPECT_BINDER_FAIL(service->getAppSize(std::nullopt, packageNames, 0,
+ InstalldNativeService::FLAG_USE_QUOTA,
+ externalStorageAppId, ceDataInodes, codePaths,
+ &externalStorageSize));
+}
static bool mkdirs(const std::string& path, mode_t mode) {
struct stat sb;
if (stat(path.c_str(), &sb) != -1 && S_ISDIR(sb.st_mode)) {