diff options
author | 2017-09-14 04:15:36 +0000 | |
---|---|---|
committer | 2017-09-14 04:15:36 +0000 | |
commit | 12ea24c31cdf3b67c99d3d3239f59fbd2e6f3d80 (patch) | |
tree | f6e25f2ca31fe476d446c082d0f452068c8a8d56 /cmds/installd/utils.cpp | |
parent | 64418b3b4502946d0154e7b10674c2816f2e2343 (diff) | |
parent | 495157b05cab033c54cf1cb2388a04fdb33d553a (diff) |
Merge "Adjust the validation code for secondary dex paths" into oc-mr1-dev
am: 495157b05c
Change-Id: I241735ef8fa01a0210582c145b26b4d50a713855
Diffstat (limited to 'cmds/installd/utils.cpp')
-rw-r--r-- | cmds/installd/utils.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp index d277bd3ad8..dd32ac6425 100644 --- a/cmds/installd/utils.cpp +++ b/cmds/installd/utils.cpp @@ -801,7 +801,7 @@ int validate_system_app_path(const char* path) { } bool validate_secondary_dex_path(const std::string& pkgname, const std::string& dex_path, - const char* volume_uuid, int uid, int storage_flag) { + const char* volume_uuid, int uid, int storage_flag, bool validate_package_path) { CHECK(storage_flag == FLAG_STORAGE_CE || storage_flag == FLAG_STORAGE_DE); // Empty paths are not allowed. @@ -815,15 +815,18 @@ bool validate_secondary_dex_path(const std::string& pkgname, const std::string& // The path should be at most PKG_PATH_MAX long. if (dex_path.size() > PKG_PATH_MAX) { return false; } - // The dex_path should be under the app data directory. - std::string app_private_dir = storage_flag == FLAG_STORAGE_CE - ? create_data_user_ce_package_path( - volume_uuid, multiuser_get_user_id(uid), pkgname.c_str()) - : create_data_user_de_package_path( - volume_uuid, multiuser_get_user_id(uid), pkgname.c_str()); - - if (strncmp(dex_path.c_str(), app_private_dir.c_str(), app_private_dir.size()) != 0) { - return false; + if (validate_package_path) { + // If we are asked to validate the package path check that + // the dex_path is under the app data directory. + std::string app_private_dir = storage_flag == FLAG_STORAGE_CE + ? create_data_user_ce_package_path( + volume_uuid, multiuser_get_user_id(uid), pkgname.c_str()) + : create_data_user_de_package_path( + volume_uuid, multiuser_get_user_id(uid), pkgname.c_str()); + + if (strncmp(dex_path.c_str(), app_private_dir.c_str(), app_private_dir.size()) != 0) { + return false; + } } // If we got here we have a valid path. |