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

Commit 2ff8b4ae authored by Jeremy Meyer's avatar Jeremy Meyer
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
Change-Id: I4247e54f3ea0d9e4bf0d9f404e0272751a258ba2
(cherry picked from commit 12e49e7a)
Merged-In: I4247e54f3ea0d9e4bf0d9f404e0272751a258ba2
parent 4d41c8ff
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 {