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

Commit 8d212986 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only allow load frro drawables from frro directory" into main

parents c13ab36a 12e49e7a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -77,6 +77,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 volatile ResourcesManager sResourcesManager;

@@ -581,7 +582,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";
    }

    /**
+12 −3
Original line number Diff line number Diff line
@@ -992,15 +992,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 {