summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@google.com>2016-01-22 22:22:25 (GMT)
committerThe Android Automerger <android-build@google.com>2016-01-22 22:46:28 (GMT)
commit616188b0a0c96e88926e84cfe156908f0da9ebe2 (patch)
tree32dc7bf958845e97f12edfa6cf6f32a665c43e58
parente74f002e6e2f8f00595e4179ed6c3f85da21796b (diff)
downloadandroid_packages_providers_DownloadProvider-616188b0a0c96e88926e84cfe156908f0da9ebe2.zip
android_packages_providers_DownloadProvider-616188b0a0c96e88926e84cfe156908f0da9ebe2.tar.gz
android_packages_providers_DownloadProvider-616188b0a0c96e88926e84cfe156908f0da9ebe2.tar.bz2
Revert "Use resolved path for both checking and opening."
This reverts commit 366af2ee1f841615d44ab770b537112d769eed05. Change-Id: Id1155425ebcae23be8ce3916f19dda82eee992c4
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java10
-rw-r--r--src/com/android/providers/downloads/Helpers.java4
2 files changed, 6 insertions, 8 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index 620085f..94e5a99 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -1260,15 +1260,9 @@ public final class DownloadProvider extends ContentProvider {
throw new FileNotFoundException("No filename found.");
}
- final File file;
- try {
- file = new File(path).getCanonicalFile();
- } catch (IOException e) {
- throw new FileNotFoundException(e.getMessage());
- }
-
+ final File file = new File(path);
if (!Helpers.isFilenameValid(getContext(), file)) {
- throw new FileNotFoundException("Invalid file path: " + file);
+ throw new FileNotFoundException("Invalid file: " + file);
}
final int pfdMode = ParcelFileDescriptor.parseMode(mode);
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index d01cbff..d1cc545 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -357,6 +357,8 @@ public class Helpers {
static boolean isFilenameValidInExternalPackage(Context context, File file,
String packageName) {
try {
+ file = file.getCanonicalFile();
+
if (containsCanonical(buildExternalStorageAppFilesDirs(packageName), file) ||
containsCanonical(buildExternalStorageAppObbDirs(packageName), file) ||
containsCanonical(buildExternalStorageAppCacheDirs(packageName), file) ||
@@ -378,6 +380,8 @@ public class Helpers {
*/
static boolean isFilenameValid(Context context, File file, boolean allowInternal) {
try {
+ file = file.getCanonicalFile();
+
if (allowInternal) {
if (containsCanonical(context.getFilesDir(), file)
|| containsCanonical(context.getCacheDir(), file)