mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-14 02:14:34 -05:00
59bf3b75c7
https://review.lineageos.org/c/LineageOS/android_frameworks_base/+/353117 https://review.lineageos.org/q/topic:Q_asb_2023-03 https://review.lineageos.org/q/topic:Q_asb_2023-04 https://review.lineageos.org/q/topic:Q_asb_2023-05 https://review.lineageos.org/q/topic:Q_asb_2023-06 https://review.lineageos.org/q/topic:Q_asb_2023-07 https://review.lineageos.org/q/topic:Q_asb_2023-08 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376560 https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376561 https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376562 https://review.lineageos.org/q/topic:Q_asb_2023-09 https://review.lineageos.org/q/topic:Q_asb_2023-10 https://review.lineageos.org/q/topic:Q_asb_2023-11 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376563 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_webp/+/376568 https://review.lineageos.org/q/topic:Q_asb_2023-12 https://review.lineageos.org/q/topic:Q_asb_2024-01 https://review.lineageos.org/q/topic:Q_asb_2024-02 https://review.lineageos.org/q/topic:Q_asb_2024-03 Signed-off-by: Tavi <tavi@divested.dev>
42 lines
1.8 KiB
Diff
42 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dipankar Bhardwaj <dipankarb@google.com>
|
|
Date: Thu, 6 Jul 2023 10:01:20 +0000
|
|
Subject: [PATCH] Canonicalize file path for insertion by legacy apps
|
|
|
|
Apps with legacy external storage can try to create entries in MP for
|
|
file paths in other apps external private directories by using a
|
|
non-canonical path in insertion calls.
|
|
|
|
Test: atest LegacyStorageHostTest#testInsertToOtherAppPrivateDirFails
|
|
Bug: 276898626
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3c0f583f5dc3f4d395fa2423ab72dbd902c0c6c8)
|
|
Merged-In: If4c941c8156f19459b3ec6cbaf705824ecc2ba77
|
|
Change-Id: If4c941c8156f19459b3ec6cbaf705824ecc2ba77
|
|
---
|
|
src/com/android/providers/media/MediaProvider.java | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
|
|
index b8ec75cdd..822d69537 100644
|
|
--- a/src/com/android/providers/media/MediaProvider.java
|
|
+++ b/src/com/android/providers/media/MediaProvider.java
|
|
@@ -1526,9 +1526,17 @@ public class MediaProvider extends ContentProvider {
|
|
values.remove(ImageColumns.PRIMARY_DIRECTORY);
|
|
values.remove(ImageColumns.SECONDARY_DIRECTORY);
|
|
|
|
- final String data = values.getAsString(MediaColumns.DATA);
|
|
+ String data = values.getAsString(MediaColumns.DATA);
|
|
if (TextUtils.isEmpty(data)) return;
|
|
|
|
+ try {
|
|
+ data = new File(data).getCanonicalPath();
|
|
+ values.put(MediaColumns.DATA, data);
|
|
+ } catch (IOException e) {
|
|
+ throw new IllegalArgumentException(
|
|
+ String.format(Locale.ROOT, "Invalid file path:%s in request.", data));
|
|
+ }
|
|
+
|
|
final File file = new File(data);
|
|
final File fileLower = new File(data.toLowerCase());
|
|
|