1
--- old/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java Tue Nov 18 10:35:29 2008
2
+++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java Tue Nov 18 10:35:29 2008
4
import java.io.FileNotFoundException;
5
import java.io.IOException;
7
+import java.security.AccessController;
8
+import java.security.PrivilegedAction;
9
import javax.accessibility.*;
11
import sun.awt.shell.ShellFolder;
16
- baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
17
+ baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
18
+ public File[] run() {
19
+ return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
23
baseFolders = fsv.getRoots();
25
--- old/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java Tue Nov 18 10:35:30 2008
26
+++ openjdk/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java Tue Nov 18 10:35:30 2008
31
+import java.security.AccessController;
32
+import java.security.PrivilegedAction;
35
import javax.swing.event.*;
40
- baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
41
+ baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
42
+ public File[] run() {
43
+ return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
47
baseFolders = fsv.getRoots();
49
--- old/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Tue Nov 18 10:35:31 2008
50
+++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Tue Nov 18 10:35:31 2008
52
import java.io.FileNotFoundException;
53
import java.io.IOException;
55
+import java.security.AccessController;
56
+import java.security.PrivilegedAction;
58
import sun.awt.shell.ShellFolder;
59
import sun.awt.OSInfo;
60
@@ -1165,7 +1167,11 @@
64
- baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
65
+ baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
66
+ public File[] run() {
67
+ return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
71
baseFolders = fsv.getRoots();
73
--- old/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java Tue Nov 18 10:35:32 2008
74
+++ openjdk/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java Tue Nov 18 10:35:32 2008
77
* <code>null</code> if this shellfolder does not denote a directory.
79
public File[] listFiles(final boolean includeHiddenFiles) {
80
+ SecurityManager security = System.getSecurityManager();
81
+ if (security != null) {
82
+ security.checkRead(getPath());
85
return new ComTask<File[]>() {
86
public File[] call() throws Exception {
87
--- /dev/null Tue Nov 18 10:35:33 2008
88
+++ openjdk/jdk/test/javax/swing/JFileChooser/6484091/bug6484091.java Tue Nov 18 10:35:33 2008
90
+/* @test @(#)bug6484091.java 1.1 08/11/18
92
+ * @summary FileSystemView leaks directory info
93
+ * @author Pavel Porvatov
94
+ @run main bug6484091
98
+import java.security.AccessControlException;
99
+import javax.swing.filechooser.FileSystemView;
100
+import javax.swing.*;
102
+import sun.awt.shell.ShellFolder;
104
+public class bug6484091 {
105
+ public static void main(String[] args) {
106
+ ShellFolder dir = (ShellFolder) FileSystemView.getFileSystemView().getDefaultDirectory();
108
+ printDirContent(dir);
110
+ System.setSecurityManager(new SecurityManager());
112
+ // The next test cases use 'dir' obtained without SecurityManager
114
+ printDirContent(dir);
116
+ throw new RuntimeException("Dir content was derived bypass SecurityManager");
117
+ } catch (AccessControlException e) {
118
+ // It's a successful situation
122
+ private static void printDirContent(File dir) {
123
+ System.out.println("Files in " + dir.getAbsolutePath() + ":");
125
+ for (File file : dir.listFiles()) {
126
+ System.out.println(file.getName());