Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37a27243 authored by Jeremy Meyer's avatar Jeremy Meyer Committed by Android Build Coastguard Worker
Browse files

Only allow load frro drawables from frro directory

Fixes: 383080440
Test: Used test app to verify drawable frros still work
Flag: EXEMPT bugfix
(cherry picked from commit 12e49e7a)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b7ae33d3d1fdb14205dea3fa3448afd7309137ac)
Merged-In: I4247e54f3ea0d9e4bf0d9f404e0272751a258ba2
Change-Id: I4247e54f3ea0d9e4bf0d9f404e0272751a258ba2
parent de4ebd5d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import java.util.function.Function;
public class ResourcesManager {
    static final String TAG = "ResourcesManager";
    private static final boolean DEBUG = false;
    public static final String RESOURCE_CACHE_DIR = "/data/resource-cache/";

    private static ResourcesManager sResourcesManager;

@@ -443,7 +444,7 @@ public class ResourcesManager {
    }

    private static String overlayPathToIdmapPath(String path) {
        return "/data/resource-cache/" + path.substring(1).replace('/', '@') + "@idmap";
        return RESOURCE_CACHE_DIR + path.substring(1).replace('/', '@') + "@idmap";
    }

    private @NonNull ApkAssets loadApkAssets(@NonNull final ApkKey key) throws IOException {
+13 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.annotation.PluralsRes;
import android.annotation.RawRes;
import android.annotation.StyleRes;
import android.annotation.StyleableRes;
import android.app.ResourcesManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo.Config;
@@ -887,15 +888,24 @@ public class ResourcesImpl {
                    } else {
                        dr = loadXmlDrawable(wrapper, value, id, density, file);
                    }
                } else if (file.startsWith("frro://")) {
                } else if (file.startsWith("frro:/")) {
                    Uri uri = Uri.parse(file);
                    long offset = Long.parseLong(uri.getQueryParameter("offset"));
                    long size = Long.parseLong(uri.getQueryParameter("size"));
                    if (offset < 0 || size <= 0) {
                        throw new NotFoundException("invalid frro parameters");
                    }
                    File f = new File('/' + uri.getHost() + uri.getPath());
                    if (!f.getCanonicalPath().startsWith(ResourcesManager.RESOURCE_CACHE_DIR)
                            || !f.getCanonicalPath().endsWith(".frro") || !f.canRead()) {
                        throw new NotFoundException("invalid frro path");
                    }
                    ParcelFileDescriptor pfd = ParcelFileDescriptor.open(f,
                            ParcelFileDescriptor.MODE_READ_ONLY);
                    AssetFileDescriptor afd = new AssetFileDescriptor(
                            pfd,
                            Long.parseLong(uri.getQueryParameter("offset")),
                            Long.parseLong(uri.getQueryParameter("size")));
                            offset,
                            size);
                    FileInputStream is = afd.createInputStream();
                    dr = decodeImageDrawable(is, wrapper);
                } else {