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

Commit d839beae authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make security warning on contains() more obvious."

parents 5837dcdb 2a7f8e6a
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -846,7 +846,16 @@ public class FileUtils {
        return contains(dir.getAbsolutePath(), file.getAbsolutePath());
    }

    /** {@hide} */
    /**
     * Test if a file lives under the given directory, either as a direct child
     * or a distant grandchild.
     * <p>
     * Both files <em>must</em> have been resolved using
     * {@link File#getCanonicalFile()} to avoid symlink or path traversal
     * attacks.
     *
     * @hide
     */
    public static boolean contains(String dirPath, String filePath) {
        if (dirPath.equals(filePath)) {
            return true;