diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-11 17:38:58 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-11 17:38:58 +0000 |
commit | 579415ab21a3f7073c43e225bcaf8aed50ad5d0f (patch) | |
tree | b63456ffdf4a4228fa5b0b442f5aae5788209864 | |
parent | 8924c3d52f89a77d8f1067b85be8e69230638e3a (diff) | |
parent | 4d94c61ec00a0e4bf592438458eaa3485b9939a5 (diff) | |
download | libcore-oreo-r2-release.tar.gz |
Merge cherrypicks of [2877873, 2877351, 2877352, 2877353, 2877568, 2877569, 2877069, 2877070, 2877071, 2877072, 2877874, 2877875, 2877876, 2877877, 2877878, 2877570, 2877571, 2877843, 2877844] into oc-r2-releaseandroid-8.0.0_r29oreo-r2-release
Change-Id: I8003253856c5c304a8e20544d827ca3b6a0a22ee
-rw-r--r-- | libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java | 3 | ||||
-rw-r--r-- | luni/src/test/java/libcore/java/io/FileTest.java | 21 | ||||
-rw-r--r-- | ojluni/src/main/java/java/io/FileSystem.java | 7 |
3 files changed, 27 insertions, 4 deletions
diff --git a/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java b/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java index 5a84c8e5375..87c309674a6 100644 --- a/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java +++ b/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java @@ -87,7 +87,7 @@ public final class AndroidHardcodedSystemProperties { // Hardcode MessagePattern apostrophe mode to be default. b/27265238 { "android.icu.text.MessagePattern.ApostropheMode", null }, - // Hardcode "sun.io.useCanonCaches" to use the default (on). b/28174137 + // Hardcode "sun.io.useCanonCaches" to use the default (off). b/28174137, b/62301183 { "sun.io.useCanonCaches", null }, { "sun.io.useCanonPrefixCache", null }, @@ -111,4 +111,3 @@ public final class AndroidHardcodedSystemProperties { { "java.util.logging.manager", null }, }; } - diff --git a/luni/src/test/java/libcore/java/io/FileTest.java b/luni/src/test/java/libcore/java/io/FileTest.java index 9226e02610f..3705f2b3c85 100644 --- a/luni/src/test/java/libcore/java/io/FileTest.java +++ b/luni/src/test/java/libcore/java/io/FileTest.java @@ -393,4 +393,25 @@ public class FileTest extends junit.framework.TestCase { fail(); } catch (InvalidPathException expected) {} } + + // http://b/62301183 + public void test_canonicalCachesAreOff() throws Exception { + File tempDir = createTemporaryDirectory(); + File f1 = new File(tempDir, "testCannonCachesOff1"); + f1.createNewFile(); + File f2 = new File(tempDir, "testCannonCachesOff2"); + f2.createNewFile(); + File symlinkFile = new File(tempDir, "symlink"); + + // Create a symlink from symlink to f1 and populate canonical path cache + assertEquals(0, Runtime.getRuntime().exec("ln -s " + f1.getAbsolutePath() + " " + symlinkFile.getAbsolutePath()).waitFor()); + assertEquals(symlinkFile.getCanonicalPath(), f1.getCanonicalPath()); + + // Remove it and replace it with a symlink to f2 (using java File/Files would flush caches). + assertEquals(0, Runtime.getRuntime().exec("rm " + symlinkFile.getAbsolutePath()).waitFor()); + assertEquals(0, Runtime.getRuntime().exec("ln -s " + f2.getAbsolutePath() + " " + symlinkFile.getAbsolutePath()).waitFor()); + + // Did we cache canonical path results? hope not! + assertEquals(symlinkFile.getCanonicalPath(), f2.getCanonicalPath()); + } } diff --git a/ojluni/src/main/java/java/io/FileSystem.java b/ojluni/src/main/java/java/io/FileSystem.java index 4b0260d449a..86d8fff2395 100644 --- a/ojluni/src/main/java/java/io/FileSystem.java +++ b/ojluni/src/main/java/java/io/FileSystem.java @@ -226,8 +226,11 @@ abstract class FileSystem { // Flags for enabling/disabling performance optimizations for file // name canonicalization - static boolean useCanonCaches = true; - static boolean useCanonPrefixCache = true; + // Android-changed: Disabled caches for security reasons (b/62301183) + //static boolean useCanonCaches = true; + //static boolean useCanonPrefixCache = true; + static boolean useCanonCaches = false; + static boolean useCanonPrefixCache = false; private static boolean getBooleanProperty(String prop, boolean defaultVal) { String val = System.getProperty(prop); |