diff options
author | Jeff Sharkey <jsharkey@google.com> | 2016-01-23 01:04:18 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-23 01:04:18 +0000 |
commit | e4f155caa7fcfe21842952b2fa45ca0ce425857d (patch) | |
tree | 5919b6ea78d59875d93a1f56e67d4d91832e7337 /src/com/android/providers/downloads | |
parent | a558609f3a9d4a7ab7a9ce03277e8ba1144a7c5c (diff) | |
parent | 15185cff911670eba8f742fe8a2f26de5ed657fe (diff) | |
download | android_packages_providers_DownloadProvider-e4f155caa7fcfe21842952b2fa45ca0ce425857d.tar.gz android_packages_providers_DownloadProvider-e4f155caa7fcfe21842952b2fa45ca0ce425857d.tar.bz2 android_packages_providers_DownloadProvider-e4f155caa7fcfe21842952b2fa45ca0ce425857d.zip |
Merge "Revert "Use resolved path for both checking and opening."" into mnc-dr1.5-dev am: ce08ce4bdb
am: 15185cff91
* commit '15185cff911670eba8f742fe8a2f26de5ed657fe':
Revert "Use resolved path for both checking and opening."
Diffstat (limited to 'src/com/android/providers/downloads')
-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, 6 insertions, 8 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index 620085fc..94e5a997 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 d01cbff2..d1cc5450 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) |