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

Commit 8478bf46 authored by Felipe Leme's avatar Felipe Leme
Browse files

Added extra validation for invalid paths.

In normal circumstances, StorageVolume can only be obtained through
StorageManager and hence it will contain a valid path internally. But
the path could be invalid in at least 2 occations:

- App maliciously changed it using reflection.
- Mounted volume was ejected.

This change improves OpenExternalDirectoryActivity so it returns a
RESULT_CANCELED upon receiveving an invalid path.

BUG: 27962875

Change-Id: Ide43968babaa37961c7b704bd289f44eac952e94
parent 9d1d006c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -212,6 +212,12 @@ public class OpenExternalDirectoryActivity extends Activity {
                break;
            }
        }
        if (internalRoot == null) {
            // Should not happen on normal circumstances, unless app crafted an invalid volume
            // using reflection or the list of mounted volumes changed.
            Log.e(TAG, "Didn't find right volume for '" + storageVolume.dump() + "' on " + volumes);
            return false;
        }

        // Checks if the user has granted the permission already.
        final Intent intent = getIntentForExistingPermission(activity, isRoot, internalRoot, file);