Make sure file paths are canonical in scanFile()
Bug: 6987701
Change-Id: I55d2f95ab63df19f9c9ba39da5215893b8e658e4
Signed-off-by: Mike Lockwood <lockwood@google.com>
diff --git a/src/com/android/providers/media/MediaScannerService.java b/src/com/android/providers/media/MediaScannerService.java
index 46e5b2e..40bb10a 100644
--- a/src/com/android/providers/media/MediaScannerService.java
+++ b/src/com/android/providers/media/MediaScannerService.java
@@ -190,7 +190,14 @@
String volumeName = MediaProvider.EXTERNAL_VOLUME;
openDatabase(volumeName);
MediaScanner scanner = createMediaScanner();
- return scanner.scanSingleFile(path, volumeName, mimeType);
+ try {
+ // make sure the file path is in canonical form
+ String canonicalPath = new File(path).getCanonicalPath();
+ return scanner.scanSingleFile(canonicalPath, volumeName, mimeType);
+ } catch (Exception e) {
+ Log.e(TAG, "bad path " + path + " in scanFile()", e);
+ return null;
+ }
}
@Override