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

Commit 5786a278 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Fix mount path prefix checking.

Uncovered as part of writing CTS tests.

Bug: 10577541
Change-Id: I7832bcd551bedeea0b2ee5d6926aba6ac9bd0fd2
parent 32cd2fb5
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2145,6 +2145,10 @@ class MountService extends IMountService.Stub
            return -1;
        }

        if (!appPath.endsWith("/")) {
            appPath = appPath + "/";
        }

        // Try translating the app path into a vold path, but require that it
        // belong to the calling package.
        String voldPath = maybeTranslatePathForVold(appPath,
@@ -2194,9 +2198,9 @@ class MountService extends IMountService.Stub
        }

        for (int i = 0; i < appPaths.length; i++) {
            final String appPath = appPaths[i].getAbsolutePath();
            final String appPath = appPaths[i].getAbsolutePath() + "/";
            if (path.startsWith(appPath)) {
                path = new File(voldPaths[i], path.substring(appPath.length() + 1))
                path = new File(voldPaths[i], path.substring(appPath.length()))
                        .getAbsolutePath();
                if (!path.endsWith("/")) {
                    path = path + "/";