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

Commit 92684fbf authored by Jeremy Meyer's avatar Jeremy Meyer Committed by Automerger Merge Worker
Browse files

Merge "Only allow load frro drawables from frro directory" into udc-dev am: 8f7e233b

parents 71d62738 8f7e233b
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 {