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

Commit 85451ee1 authored by San Mehat's avatar San Mehat
Browse files

MountService: Fix bug which would allow apps to try to rename a container whos dst is mounted



Signed-off-by: default avatarSan Mehat <san@google.com>
parent 9ff1f96f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1003,7 +1003,11 @@ class MountService extends IMountService.Stub
        warnOnNotMounted();

        synchronized (mAsecMountSet) {
            if (mAsecMountSet.contains(oldId)) {
            /*
             * Because a mounted container has active internal state which cannot be 
             * changed while active, we must ensure both ids are not currently mounted.
             */
            if (mAsecMountSet.contains(oldId) || mAsecMountSet.contains(newId)) {
                return StorageResultCode.OperationFailedStorageMounted;
            }
        }
+5 −2
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ public class AsecTests extends AndroidTestCase {
        }
    }

    public void testRenameMountedContainer() {
    public void testRenameSrcMountedContainer() {
        try {
            Assert.assertEquals(StorageResultCode.OperationSucceeded,
                    createContainer("testRenameContainer.1", 4, "none"));
@@ -312,11 +312,14 @@ public class AsecTests extends AndroidTestCase {
        }
    }

    public void testRenameToExistingContainer() {
    public void testRenameDstMountedContainer() {
        try {
            Assert.assertEquals(StorageResultCode.OperationSucceeded,
                    createContainer("testRenameContainer.1", 4, "none"));

            Assert.assertEquals(StorageResultCode.OperationSucceeded,
                    unmountContainer("testRenameContainer.1", false));

            Assert.assertEquals(StorageResultCode.OperationSucceeded,
                    createContainer("testRenameContainer.2", 4, "none"));