Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 107395 Details for
Bug 240704
[cleanup] Protect against illegal API use of getRemoteFileObject() with relative path as name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch fixing the issue
Bug240704_illegalApi.diff.txt (text/plain), 12.98 KB, created by
Martin Oberhuber
on 2008-07-14 18:44:17 EDT
(
hide
)
Description:
Patch fixing the issue
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2008-07-14 18:44:17 EDT
Size:
12.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.tests >Index: src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java,v >retrieving revision 1.18 >diff -u -r1.18 FileSubsystemConsistencyTestCase.java >--- src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java 14 Jul 2008 22:40:52 -0000 1.18 >+++ src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java 14 Jul 2008 22:43:46 -0000 >@@ -11,6 +11,7 @@ > * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants > * Martin Oberhuber (Wind River) - organize, enable and tag test cases > * Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases >+ * Martin Oberhuber (Wind River) - [240704] Protect against illegal API use of getRemoteFileObject() with relative path as name > *******************************************************************************/ > package org.eclipse.rse.tests.subsystems.files; > >@@ -471,4 +472,30 @@ > } > } > >+ public void testGetRemoteFileRelativePath() throws Exception { >+ // for bug 240704 >+ // -test-author-:MartinOberhuber >+ if (isTestDisabled()) >+ return; >+ setupConnections(); >+ for (int i = 0; i < _subSystems.size(); i++) { >+ IRemoteFileSubSystem ss = (IRemoteFileSubSystem) _subSystems.get(i); >+ ss.checkIsConnected(getDefaultProgressMonitor()); >+ IRemoteFile homeDir = ss.getRemoteFileObject(".", getDefaultProgressMonitor()); >+ assertTrue(homeDir.exists()); >+ assertTrue(homeDir.isDirectory()); >+ String sep = homeDir.getSeparator(); >+ String relativePath = "rsetest" + System.currentTimeMillis() + sep + "foo" + sep + "bar"; >+ try { >+ IRemoteFile subDir = ss.getRemoteFileObject(homeDir, relativePath, getDefaultProgressMonitor()); >+ assertTrue(subDir.isDescendantOf(homeDir)); >+ assertEquals("bar", subDir.getName()); >+ assertFalse(subDir.exists()); >+ assertFalse(subDir.isDirectory()); >+ } catch (IllegalArgumentException e) { >+ // Expected here: IllegalArgumentException is OK >+ } >+ } >+ } >+ > } >#P org.eclipse.rse.subsystems.files.core >Index: build.properties >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/build.properties,v >retrieving revision 1.10 >diff -u -r1.10 build.properties >--- build.properties 7 Jan 2008 14:21:41 -0000 1.10 >+++ build.properties 14 Jul 2008 22:43:47 -0000 >@@ -7,6 +7,7 @@ > # > # Contributors: > # IBM Corporation - initial API and implementation >+# Martin Oberhuber (Wind River) - [240704] Protect against illegal API use of getRemoteFileObject() with relative path as name > ############################################################################### > bin.includes = META-INF/,\ > about.html,\ >@@ -15,5 +16,8 @@ > . > source.. = src/ > output.. = bin/ >+ >+javacSource=1.4 >+javacTarget=1.4 > src.includes = about.html,\ > schema/ >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/META-INF/MANIFEST.MF,v >retrieving revision 1.21 >diff -u -r1.21 MANIFEST.MF >--- META-INF/MANIFEST.MF 21 May 2008 12:57:45 -0000 1.21 >+++ META-INF/MANIFEST.MF 14 Jul 2008 22:43:47 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName > Bundle-SymbolicName: org.eclipse.rse.subsystems.files.core;singleton:=true >-Bundle-Version: 3.0.0.qualifier >+Bundle-Version: 3.0.1.qualifier > Bundle-Activator: org.eclipse.rse.internal.subsystems.files.core.Activator > Bundle-Localization: plugin > Require-Bundle: org.eclipse.ui, >Index: .settings/org.eclipse.jdt.core.prefs >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/.settings/org.eclipse.jdt.core.prefs,v >retrieving revision 1.4 >diff -u -r1.4 org.eclipse.jdt.core.prefs >--- .settings/org.eclipse.jdt.core.prefs 28 Mar 2008 13:22:22 -0000 1.4 >+++ .settings/org.eclipse.jdt.core.prefs 14 Jul 2008 22:43:47 -0000 >@@ -1,7 +1,7 @@ > #Fri Mar 28 14:14:24 CET 2008 > eclipse.preferences.version=1 > org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled >-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 >+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 > org.eclipse.jdt.core.compiler.compliance=1.4 > org.eclipse.jdt.core.compiler.doc.comment.support=enabled > org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning >@@ -68,4 +68,4 @@ > org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled > org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning > org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning >-org.eclipse.jdt.core.compiler.source=1.3 >+org.eclipse.jdt.core.compiler.source=1.4 >Index: src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java,v >retrieving revision 1.74 >diff -u -r1.74 FileServiceSubSystem.java >--- src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java 6 Jun 2008 17:54:24 -0000 1.74 >+++ src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java 14 Jul 2008 22:43:47 -0000 >@@ -41,6 +41,7 @@ > * Martin Oberhuber (Wind River) - [234038] Mark IRemoteFile stale when changing permissions > * Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile > * David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter >+ * Martin Oberhuber (Wind River) - [240704] Protect against illegal API use of getRemoteFileObject() with relative path as name > *******************************************************************************/ > > package org.eclipse.rse.subsystems.files.core.servicesubsystem; >@@ -54,6 +55,7 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Status; > import org.eclipse.osgi.util.NLS; > import org.eclipse.rse.core.RSECorePlugin; > import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; >@@ -73,6 +75,7 @@ > import org.eclipse.rse.services.clientserver.messages.CommonMessages; > import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; > import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; >+import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException; > import org.eclipse.rse.services.clientserver.messages.SystemMessage; > import org.eclipse.rse.services.clientserver.messages.SystemMessageException; > import org.eclipse.rse.services.files.IFileService; >@@ -174,6 +177,9 @@ > */ > public IRemoteFile getRemoteFileObject(IRemoteFile parent, String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException > { >+ // Consistency would be totally messed up if folderOrFileName were a relative path >+ // Because IHostFiles would be incorrectly generated, getParent() would return wrong results etc >+ assert folderOrFileName.indexOf(getSeparator())<0; > // for bug 207095, implicit connect if the connection is not connected > checkIsConnected(monitor); > >@@ -183,6 +189,17 @@ > { > return file; > } >+ // Fallback in case of incorrect API usage >+ // TODO remove this in next release for Performance, >+ // since it is just for bad clients using the API incorrectly >+ if (folderOrFileName.indexOf(getSeparator()) >= 0) { >+ try { >+ throw new IllegalArgumentException("getRemoteFileObject: folderOrFileName must not be a relative path"); //$NON-NLS-1$ >+ } catch (IllegalArgumentException e) { >+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Illegal API use: " + e.getLocalizedMessage(), e)); //$NON-NLS-1$ >+ } >+ return getRemoteFileObject(fullPath, monitor); >+ } > > IHostFile node = getFile(parent.getAbsolutePath(), folderOrFileName, monitor); > return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, node); >@@ -420,16 +437,16 @@ > } > > List hostFiles = new ArrayList(10); >- >+ > // query children via the service > getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor); > RemoteFileContext context = getDefaultContext(); > >- IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); >+ IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); > > // convert the IHostFiles into AbstractRemoteFiles > AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); >- >+ > // cache the results corresponding to each parent under each parent > for (int i = 0; i < parents.length; i++) > { >@@ -449,14 +466,14 @@ > underParent.add(child); > } > } >- >+ > // update the parent with it's latest properties > // null is passed for the second argument because we currently don't get the parent in our results query >- updateRemoteFile(parent, null, monitor); >- >+ updateRemoteFile(parent, null, monitor); >+ > if (underParent.size() > 0) > { >- Object[] qresults = underParent.toArray(); >+ Object[] qresults = underParent.toArray(); > parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); > } > } >@@ -483,11 +500,11 @@ > getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); > RemoteFileContext context = getDefaultContext(); > >- IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); >- >+ IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); >+ > // convert the IHostFiles into AbstractRemoteFiles > AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); >- >+ > // cache the results corresponding to each parent under each parent > for (int i = 0; i < parents.length; i++) > { >@@ -510,11 +527,11 @@ > > // update the parent with it's latest properties > // null is passed for the second argument because we currently don't get the parent in our results query >- updateRemoteFile(parent, null, monitor); >- >+ updateRemoteFile(parent, null, monitor); >+ > if (underParent.size() > 0) > { >- Object[] qresults = underParent.toArray(); >+ Object[] qresults = underParent.toArray(); > parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); > } > } >@@ -544,14 +561,14 @@ > IStatus.INFO, msgTxt); > throw new SystemMessageException(msg); > } >- >+ > // query children of the parent >- IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); >- >+ IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); >+ > // update the parent with it's latest properties > // null is passed for the second argument because we currently don't get the parent in our results query > updateRemoteFile(parent, null, monitor); >- >+ > // convert the IHostFiles to AbstractRemoteFile[] > AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); > if (parent != null) >@@ -559,19 +576,19 @@ > return farr; > } > >- >- >+ >+ > private void updateRemoteFile(IRemoteFile parent, IHostFile newHostParent, IProgressMonitor monitor) throws SystemMessageException >- { >+ { > // now newHostParent file passed in so we'll assume it wasn't returned and explicitly get it >- if (newHostParent == null){ >+ if (newHostParent == null){ > String parentParentPath = parent.getParentPath(); > if (parentParentPath == null){ > parentParentPath = ""; //$NON-NLS-1$ > } > newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor); > } >- >+ > if (newHostParent != null){ > IHostFile oldHostParent = parent.getHostFile(); > if (!newHostParent.equals(oldHostParent)){ >@@ -581,7 +598,7 @@ > } > } > >- >+ > public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException > { > IHostFile[] roots = null; >@@ -907,7 +924,7 @@ > > public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException > { >- return createFolder(folderToCreate, monitor); >+ return createFolder(folderToCreate, monitor); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 240704
: 107395