diff options
author | Jeff Sharkey <jsharkey@android.com> | 2016-01-15 19:01:50 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-15 19:01:50 +0000 |
commit | 06ed2539f5172289f5a1dc14e37b4f151251f590 (patch) | |
tree | 104a6254f3cd3053230d5f266fb477a6dd5cea6a | |
parent | b54f5f60ef0e41cf75c2156a5da67ce9858ccf9c (diff) | |
parent | 6608eb8feedafab93b840c208a40aa6d6c755584 (diff) | |
download | android_packages_providers_DownloadProvider-06ed2539f5172289f5a1dc14e37b4f151251f590.tar.gz android_packages_providers_DownloadProvider-06ed2539f5172289f5a1dc14e37b4f151251f590.tar.bz2 android_packages_providers_DownloadProvider-06ed2539f5172289f5a1dc14e37b4f151251f590.zip |
Use resolved path for both checking and opening.
am: 6608eb8fee
* commit '6608eb8feedafab93b840c208a40aa6d6c755584':
Use resolved path for both checking and opening.
-rw-r--r-- | src/com/android/providers/downloads/DownloadProvider.java | 10 | ||||
-rw-r--r-- | src/com/android/providers/downloads/Helpers.java | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index 94e5a997..620085fc 100644 --- a/src/com/android/providers/downloads/DownloadProvider.java +++ b/src/com/android/providers/downloads/DownloadProvider.java @@ -1260,9 +1260,15 @@ public final class DownloadProvider extends ContentProvider { throw new FileNotFoundException("No filename found."); } - final File file = new File(path); + final File file; + try { + file = new File(path).getCanonicalFile(); + } catch (IOException e) { + throw new FileNotFoundException(e.getMessage()); + } + if (!Helpers.isFilenameValid(getContext(), file)) { - throw new FileNotFoundException("Invalid file: " + file); + throw new FileNotFoundException("Invalid file path: " + 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 d1cc5450..d01cbff2 100644 --- a/src/com/android/providers/downloads/Helpers.java +++ b/src/com/android/providers/downloads/Helpers.java @@ -357,8 +357,6 @@ 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) || @@ -380,8 +378,6 @@ 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) |