Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c20d957 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4383207 from 3bafe396 to pi-release

Change-Id: I8ecc5550d4df7f0fb07148d01cb8d0ee1027a04e
parents e092661b 3bafe396
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -168,12 +168,6 @@ TEST_F(UtilsTest, IsValidApkPath_EscapeFail) {
            << badasec1 << " should be rejected as a invalid path";
}

TEST_F(UtilsTest, IsValidApkPath_DoubleSlashFail) {
    const char *badasec2 = TEST_ASEC_DIR "com.example.asec//pkg.apk";
    EXPECT_EQ(-1, validate_apk_path(badasec2))
            << badasec2 << " should be rejected as a invalid path";
}

TEST_F(UtilsTest, IsValidApkPath_SubdirEscapeFail) {
    const char *badasec3 = TEST_ASEC_DIR "com.example.asec/../../../pkg.apk";
    EXPECT_EQ(-1, validate_apk_path(badasec3))
@@ -451,5 +445,29 @@ TEST_F(UtilsTest, ValidateSecondaryDexFilesPath) {
        package_name, app_dir_ce_user_10 + "/" + too_long, app_uid_for_user_10, FLAG_STORAGE_CE);
}

TEST_F(UtilsTest, ValidateApkPath) {
    EXPECT_EQ(0, validate_apk_path("/data/app/com.example"));
    EXPECT_EQ(0, validate_apk_path("/data/app/com.example/file"));
    EXPECT_EQ(0, validate_apk_path("/data/app/com.example//file"));
    EXPECT_NE(0, validate_apk_path("/data/app/com.example/dir/"));
    EXPECT_NE(0, validate_apk_path("/data/app/com.example/dir/file"));
    EXPECT_NE(0, validate_apk_path("/data/app/com.example/dir/dir/file"));
    EXPECT_NE(0, validate_apk_path("/data/app/com.example/dir/dir//file"));
    EXPECT_NE(0, validate_apk_path("/data/app/com.example/dir/dir/dir/file"));
    EXPECT_NE(0, validate_apk_path("/data/app/com.example/dir/dir/dir//file"));
}

TEST_F(UtilsTest, ValidateApkPathSubdirs) {
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example"));
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example/file"));
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example//file"));
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example/dir/"));
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example/dir/file"));
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example/dir/dir/file"));
    EXPECT_EQ(0, validate_apk_path_subdirs("/data/app/com.example/dir/dir//file"));
    EXPECT_NE(0, validate_apk_path_subdirs("/data/app/com.example/dir/dir/dir/file"));
    EXPECT_NE(0, validate_apk_path_subdirs("/data/app/com.example/dir/dir/dir//file"));
}

}  // namespace installd
}  // namespace android
+5 −2
Original line number Diff line number Diff line
@@ -756,9 +756,12 @@ static int validate_path(const std::string& dir, const std::string& path, int ma
    auto pos = path.find('/', dir.size());
    int count = 0;
    while (pos != std::string::npos) {
        pos = path.find('/', pos + 1);
        auto next = path.find('/', pos + 1);
        if (next > pos + 1) {
            count++;
        }
        pos = next;
    }

    if (count > maxSubdirs) {
        LOG(ERROR) << "Invalid path depth " << path << " when tested against " << dir;
+5 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@

#include "SchedulingPolicyService.h"

#include <private/android_filesystem_config.h> // for AID_CAMERASERVER

#include <log/log.h>
#include <hwbinder/IPCThreadState.h>
#include <mediautils/SchedulingPolicyService.h>
@@ -28,8 +30,9 @@ namespace V1_0 {
namespace implementation {

bool SchedulingPolicyService::isAllowed() {
    // TODO(b/37291237)
    return true;
    using ::android::hardware::IPCThreadState;

    return IPCThreadState::self()->getCallingUid() == AID_CAMERASERVER;
}

Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) {