summaryrefslogtreecommitdiff
path: root/services/incremental/IncrementalService.cpp
diff options
context:
space:
mode:
author Songchun Fan <schfan@google.com> 2020-01-31 16:52:41 -0800
committer Songchun Fan <schfan@google.com> 2020-01-31 19:48:35 -0800
commit54c6aed58d3030ad4ecd5a22fcf702f0f1256604 (patch)
tree3bf81bd6559adb5ecd89bab82823bc61070243fd /services/incremental/IncrementalService.cpp
parente0fb3e2dcd6c4a54e8cf1696fbeb174b0985c22d (diff)
make adb install --incremental work
With a simple Java apk (flipboard.app). BUG: 133435829 Test: manual Change-Id: If702afffc0e01cbb03f88560c0569fd23dda2350
Diffstat (limited to 'services/incremental/IncrementalService.cpp')
-rw-r--r--services/incremental/IncrementalService.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 414c66c866db..e4a37dde7758 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -30,7 +30,6 @@
#include <binder/BinderService.h>
#include <binder/ParcelFileDescriptor.h>
#include <binder/Status.h>
-
#include <openssl/sha.h>
#include <sys/stat.h>
#include <uuid/uuid.h>
@@ -612,13 +611,18 @@ int IncrementalService::bind(StorageId storage, std::string_view source, std::st
if (!ifs) {
return -EINVAL;
}
- auto normSource = path::normalize(source);
std::unique_lock l(ifs->lock);
const auto storageInfo = ifs->storages.find(storage);
if (storageInfo == ifs->storages.end()) {
return -EINVAL;
}
+ std::string normSource;
+ if (path::isAbsolute(source)) {
+ normSource = path::normalize(source);
+ } else {
+ normSource = path::normalize(path::join(storageInfo->second.name, source));
+ }
if (!path::startsWith(normSource, storageInfo->second.name)) {
return -EINVAL;
}
@@ -673,7 +677,20 @@ int IncrementalService::unbind(StorageId storage, std::string_view target) {
int IncrementalService::makeFile(StorageId storage, std::string_view path, int mode, FileId id,
incfs::NewFileParams params) {
if (auto ifs = getIfs(storage)) {
- auto err = mIncFs->makeFile(ifs->control, path, mode, id, params);
+ const auto storageInfo = ifs->storages.find(storage);
+ if (storageInfo == ifs->storages.end()) {
+ return -EINVAL;
+ }
+ std::string normPath;
+ if (path::isAbsolute(path)) {
+ normPath = path::normalize(path);
+ } else {
+ normPath = path::normalize(path::join(storageInfo->second.name, path));
+ }
+ if (!path::startsWith(normPath, storageInfo->second.name)) {
+ return -EINVAL;
+ }
+ auto err = mIncFs->makeFile(ifs->control, normPath, mode, id, params);
if (err) {
return err;
}