diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-23 19:10:23 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-23 19:10:23 +0000 |
commit | 126f450e8cbb75b525b9474c12342c5c20d6c6c1 (patch) | |
tree | 5edf3421adbd0d6dacdecdc1a719ca12d1c72920 | |
parent | baa801057fe2f44eee1af2807dcdcc62ba187d83 (diff) | |
parent | 314f9222402d3e1237fd5e78264e472a1e4474c6 (diff) | |
download | libcore-nougat-mr1.5-release.tar.gz |
Merge cherrypicks of [2780919, 2780841, 2780458, 2780892, 2780893, 2781183, 2781184, 2780842, 2780843, 2780920, 2780921, 2780922, 2780923, 2780924, 2780925, 2780926, 2780927, 2780894, 2780895, 2781304, 2780844, 2780845, 2780846, 2781209] into nyc-mr1-security-e-releaseandroid-7.1.1_r55nougat-mr1.5-release
Change-Id: Ib0eba4cf670b6a097278da0ae6d466648350270c
-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 | ||||
-rwxr-xr-x | 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 13e931786ab..7e79e2807a7 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 }, @@ -108,4 +108,3 @@ public final class AndroidHardcodedSystemProperties { { "com.sun.security.preserveOldDCEncoding", null }, }; } - diff --git a/luni/src/test/java/libcore/java/io/FileTest.java b/luni/src/test/java/libcore/java/io/FileTest.java index 5d5317a9e24..04de7513772 100644 --- a/luni/src/test/java/libcore/java/io/FileTest.java +++ b/luni/src/test/java/libcore/java/io/FileTest.java @@ -368,4 +368,25 @@ public class FileTest extends junit.framework.TestCase { assertEquals("/foo/bar", new File("/foo/", "/bar/").getPath()); assertEquals("/foo/bar", new File("/foo", "/bar//").getPath()); } + + // 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 aa00fa99693..7db1651f532 100755 --- a/ojluni/src/main/java/java/io/FileSystem.java +++ b/ojluni/src/main/java/java/io/FileSystem.java @@ -232,8 +232,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); |