diff options
author | Jeff Sharkey <jsharkey@android.com> | 2016-01-15 19:01:51 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-15 19:01:51 +0000 |
commit | 0e710ca30d0b04843b3d2e83755e35fe092cfd4a (patch) | |
tree | 918c22ecbe3b8b0da680b6c29dd6c4c60afd1065 | |
parent | 35558a84c1f211005091f3e3b622631d8a21023b (diff) | |
parent | bdc831357e7a116bc561d51bf2ddc85ff11c01a9 (diff) | |
download | android_packages_providers_DownloadProvider-0e710ca30d0b04843b3d2e83755e35fe092cfd4a.tar.gz android_packages_providers_DownloadProvider-0e710ca30d0b04843b3d2e83755e35fe092cfd4a.tar.bz2 android_packages_providers_DownloadProvider-0e710ca30d0b04843b3d2e83755e35fe092cfd4a.zip |
Use resolved path for both checking and opening.
am: bdc831357e
* commit 'bdc831357e7a116bc561d51bf2ddc85ff11c01a9':
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 | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index 4b23024f..2d914c41 100644 --- a/src/com/android/providers/downloads/DownloadProvider.java +++ b/src/com/android/providers/downloads/DownloadProvider.java @@ -1230,9 +1230,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 0aa49c0a..1b4c911e 100644 --- a/src/com/android/providers/downloads/Helpers.java +++ b/src/com/android/providers/downloads/Helpers.java @@ -341,7 +341,6 @@ public class Helpers { static boolean isFilenameValid(Context context, File file) { final File[] whitelist; try { - file = file.getCanonicalFile(); whitelist = new File[] { context.getFilesDir().getCanonicalFile(), context.getCacheDir().getCanonicalFile(), |