diff options
author | Jeff Sharkey <jsharkey@android.com> | 2016-01-15 19:08:43 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-15 19:08:43 +0000 |
commit | c64ced184cc4545303bdd13b8060f3111e256307 (patch) | |
tree | eb966a1d6b1fb572ccb1baf24f78707cac0502ec | |
parent | 5332ab3e035389445ff9351a34c1d7c94fefa318 (diff) | |
parent | 0e710ca30d0b04843b3d2e83755e35fe092cfd4a (diff) | |
download | android_packages_providers_DownloadProvider-c64ced184cc4545303bdd13b8060f3111e256307.tar.gz android_packages_providers_DownloadProvider-c64ced184cc4545303bdd13b8060f3111e256307.tar.bz2 android_packages_providers_DownloadProvider-c64ced184cc4545303bdd13b8060f3111e256307.zip |
Use resolved path for both checking and opening. am: bdc831357e
am: 0e710ca30d
* commit '0e710ca30d0b04843b3d2e83755e35fe092cfd4a':
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(), |