summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-09-25 14:19:04 -0700
committerJeff Sharkey <jsharkey@android.com>2013-09-25 14:19:10 -0700
commit776e4f7991c4f5637f9a945ed9190a26ff295446 (patch)
tree624388e9f63616366bd4f41cf8d345864e95204a /src
parentc067c8be21dc4a6dc5f49b2b1aed7f91aab47063 (diff)
downloadandroid_packages_providers_DownloadProvider-776e4f7991c4f5637f9a945ed9190a26ff295446.tar.gz
android_packages_providers_DownloadProvider-776e4f7991c4f5637f9a945ed9190a26ff295446.tar.bz2
android_packages_providers_DownloadProvider-776e4f7991c4f5637f9a945ed9190a26ff295446.zip
Always check against canonical paths.
Bug: 10920351 Change-Id: I8c7e5344d9fd9d15565eaf93b91ce457a98ab98c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/downloads/Helpers.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index aa763de2..013faf27 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -344,16 +344,26 @@ public class Helpers {
* Checks whether the filename looks legitimate
*/
static boolean isFilenameValid(String filename, File downloadsDataDir) {
+ final String[] whitelist;
try {
filename = new File(filename).getCanonicalPath();
+ whitelist = new String[] {
+ downloadsDataDir.getCanonicalPath(),
+ Environment.getDownloadCacheDirectory().getCanonicalPath(),
+ Environment.getExternalStorageDirectory().getCanonicalPath(),
+ };
} catch (IOException e) {
Log.w(TAG, "Failed to resolve canonical path: " + e);
return false;
}
- return filename.startsWith(Environment.getDownloadCacheDirectory().toString())
- || filename.startsWith(downloadsDataDir.toString())
- || filename.startsWith(Environment.getExternalStorageDirectory().toString());
+ for (String test : whitelist) {
+ if (filename.startsWith(test)) {
+ return true;
+ }
+ }
+
+ return false;
}
/**