# HG changeset patch # User kaddepalli # Date 1531506139 25200 # Node ID 7358ced1457423a7e99d2ff0e493678c6861cb2a # Parent 568328b5aea2d44bef5c2c69c52e5114d9adf96f 8194546: Choosier FileManagers Reviewed-by: prr, serb, skoivu, rhalade diff -r 568328b5aea2 -r 7358ced14574 src/windows/classes/sun/awt/shell/Win32ShellFolder2.java --- a/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java Wed Apr 18 22:35:30 2018 -0700 +++ b/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java Fri Jul 13 11:22:19 2018 -0700 @@ -677,7 +677,7 @@ security.checkRead(getPath()); } - return new ComTask() { + File[] files = new ComTask() { public File[] call() throws Exception { if (!isDirectory()) { return null; @@ -730,6 +730,8 @@ return (ShellFolder[])list.toArray(new ShellFolder[list.size()]); } }.execute(); + + return Win32ShellFolderManager2.checkFiles(files); } diff -r 568328b5aea2 -r 7358ced14574 src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java --- a/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Wed Apr 18 22:35:30 2018 -0700 +++ b/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Fri Jul 13 11:22:19 2018 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -338,21 +338,30 @@ return null; } - private File checkFile(File file) { + private static File checkFile(File file) { SecurityManager sm = System.getSecurityManager(); return (sm == null || file == null) ? file : checkFile(file, sm); } - private File checkFile(File file, SecurityManager sm) { + private static File checkFile(File file, SecurityManager sm) { try { sm.checkRead(file.getPath()); + + if (file instanceof Win32ShellFolder2) { + Win32ShellFolder2 f = (Win32ShellFolder2)file; + if (f.isLink()) { + Win32ShellFolder2 link = (Win32ShellFolder2)f.getLinkLocation(); + if (link != null) + sm.checkRead(link.getPath()); + } + } return file; } catch (SecurityException se) { return null; } } - private File[] checkFiles(File[] files) { + static File[] checkFiles(File[] files) { SecurityManager sm = System.getSecurityManager(); if (sm == null || files == null || files.length == 0) { return files; @@ -360,7 +369,7 @@ return checkFiles(Arrays.asList(files), sm); } - private File[] checkFiles(List files) { + private static File[] checkFiles(List files) { SecurityManager sm = System.getSecurityManager(); if (sm == null || files.isEmpty()) { return files.toArray(new File[files.size()]); @@ -368,7 +377,7 @@ return checkFiles(files, sm); } - private File[] checkFiles(List files, SecurityManager sm) { + private static File[] checkFiles(List files, SecurityManager sm) { List checkedFiles = new ArrayList(files.size()); for (File file: files) { if(checkFile(file, sm) != null){