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

Commit 12e49e7a 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
parent a86cdec6
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 {